Good Time.
I'm trying to integrate the Spring MVC and Apache Tiles. The problem is^ when I hit the url I need, the "404 Not Found" raises. Here are my settings:
web.xml
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Administration Panel</display-name>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
tiles.xml
<tiles-definitions>
<definition name="layout" template="/WEB-INF/jsp/templates/layout.jsp">
<put-attribute name="title" value=""/>
<put-attribute name="header" value="layout.header"/>
<put-attribute name="navigator" value="layout.navigator"/>
<put-attribute name="body" value=""/>
<put-attribute name="footer" value="layout.footer"/>
</definition>
<!-- The header template -->
<definition name="layout.header" template="/WEB-INF/jsp/templates/header.jsp">
<put-attribute name="header.left" value="/WEB-INF/jsp/themes/basic/header/layout_header_left.jsp"/>
<put-attribute name="header.center" value="/WEB-INF/jsp/themes/basic/header/layout_header_center.jsp"/>
<put-attribute name="header.right" value="/WEB-INF/jsp/themes/basic/header/layout_header_right.jsp"/>
</definition>
<!-- The navigator template -->
<definition name="layout.navigator" template="/WEB-INF/jsp/templates/navigator.jsp">
<put-attribute name="navigator.top" value="/WEB-INF/jsp/themes/basic/navigator/layout_navigator_top.jsp"/>
<put-attribute name="navigator.bottom" value="/WEB-INF/jsp/themes/basic/navigator/layout_navigator_bottom.jsp"/>
</definition>
<!-- The footer template -->
<definition name="layout.footer" template="/WEB-INF/jsp/templates/footer.jsp">
<put-attribute name="footer.left" value="/WEB-INF/jsp/themes/basic/footer/layout_footer_left.jsp"/>
<put-attribute name="footer.center" value="/WEB-INF/jsp/themes/basic/footer/layout_footer_center.jsp"/>
<put-attribute name="footer.right" value="/WEB-INF/jsp/themes/basic/footer/layout_footer_right.jsp"/>
</definition>
<definition name="blank" extends="layout">
<put-attribute name="body" value="/WEB-INF/jsp/themes/basic/body/layout_body.jsp"/>
</definition>
</tiles-definitions>
mvc-dispatcher-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<context:component-scan base-package="xxx.xxx" />
<context:annotation-config/>
<mvc:annotation-driven />
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
</bean>
</beans>
controller
@Controller
@RequestMapping("/base_page")
public class BasePageController {
@RequestMapping("/blank")
public ModelAndView getBasePage(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("blank");
return modelAndView;
}
}
The requested url is: http://localhost:8080/base_page/blank
(tomcat 7)
Can anybody suggest the solution?
Thanks Xaerxess and axtavt!
The problem is solved, as axtavt pointed, by changing /*
to /admin/*
.
Now the question is why Spring is looking for the applicationContext.xml when the xxx-servlet.xml is already here? And what type of beans are required to be placed in the applicationContext.xml (not in other spring configuration files)?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.