[Spring 2.5][Tiles2] problème de Configuration
Bonjour à tous,
Je suis en train de galérer avec la configuration de titles2 avec Spring 2.5.
Toutes mes pages jsp sont sous des répertoires différents.
Code:
1 2 3 4
|
/WEB-INF/jsp/user/list.jsp
/WEB-INF/jsp/info/about.jsp
... |
Tout fonctionne normalement pour les pages dont le contenu est juste textuel et sans contrôleur. En revanche pour les pages jsp avec un contrôleur, Spring n'arrive pas identifier les mapper avec contrôleur correspondant !
Il m'affiche ce message d'erreur suivant :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
20 janv. 2009 01:31:22 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: "Servlet.service()" pour la servlet dispatcher a générer une exception
org.apache.tiles.definition.NoSuchDefinitionException: user/list
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:394)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:370)
at org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:63)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:239)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1158)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
2009-01-20 01:31:22,272 WARN [org.apache.tiles.impl.BasicTilesContainer] - <Unable to find the definition 'user/list'> |
Voici ma configuration :
/****************templates.xml************/
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<!-- Default Main Template -->
<definition name=".mainTemplate" template="/views/templates/main.jsp">
<put-attribute name="title" value="${title}" />
<put-attribute name="header" value="/views/templates/header.jsp" />
<put-attribute name="menu" value="/views/templates/menu.jsp" />
<put-attribute name="content" value="/views/templates/blank.jsp" />
<put-attribute name="footer" value="/views/templates/footer.jsp" />
</definition>
<definition name="home" extends=".mainTemplate">
<put-attribute name="title" value="title.home"/>
<put-attribute name="content" value="/WEB-INF/jsp/home.jsp" />
</definition>
<definition name="info/about" extends=".mainTemplate">
<put-attribute name="title" value="title.home"/>
<put-attribute name="content" value="/WEB-INF/jsp/info/about.jsp" />
</definition>
<definition name="/user/list" extends=".mainTemplate">
<put-attribute name="title" value="title.home"/>
<put-attribute name="content" value="/WEB-INF/jsp/user/list.jsp" />
</definition> |
/****************menu.jsp************/
Code:
1 2 3 4 5 6 7
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<p><a href="<c:url value="/"/>">home</a></p>
<p><a href="<c:url value="/info/about.html"/>">about</a></p>
<p><a href="<c:url value="/user/list.html"/>">User Manager</a></p> |
/****************dispatcher-servlet.xml************/
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors" ref="localeChangeInterceptor" />
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles-defs/templates.xml</value>
</list>
</property>
</bean>
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="order" value="0" />
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
</bean>
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="1" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean> |
/****************web.xml ***********/
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/properties/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>1000</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>encoding-filter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding-filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>10</session-timeout>
</session-config>
<!-- <welcome-file-list>
<welcome-file>/WEB-INF/jsp/index.jsp</welcome-file>
</welcome-file-list>-->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/jsp/error/error.jsp</location>
</error-page>
<jsp-config>
<taglib>
<taglib-uri>/spring</taglib-uri>
<taglib-location>/WEB-INF/spring.tld</taglib-location>
</taglib>
</jsp-config>
</web-app> |
/*********************UserController.java*******************/
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
@Controller
@SessionAttributes("person")
public class PersonController {
@Autowired
private PersonService service;
/*public void setService(PersonService service) {
this.service = service;
}*/
@RequestMapping("user/list.html")
public String list(ModelMap model) {
model.addAttribute("personList", service.getAll());
return "user/list";
}
@RequestMapping("user/view.html")
public ModelMap view(@RequestParam("personId")long personId, ModelMap model) {
model.addAttribute("person", service.get(personId));
return model;
}
@RequestMapping("user/delete.html")
public String delete(@RequestParam("personId")long personId) {
service.removeById(personId);
return "redirect:user/list.html";
}
@RequestMapping(value = { "user/create.html", "user/update.html" }, method = RequestMethod.GET)
public String setupForm(ModelMap model, WebRequest request) {
String personId = request.getParameter("personId");
if (personId == null) {//Create Person
model.addAttribute("person", new Person());
} else {//update Person
model.addAttribute("person", service.get(Long.parseLong(personId)));
}
return "user/form";
}
@RequestMapping(value = "user/form.html", method = RequestMethod.POST)
public String submit(@ModelAttribute("person")Person person, BindingResult result, SessionStatus status) {
new PersonValidator(service).validate(person, result);
if (result.hasErrors()) {
return "user/form";
} else {
service.save(person);
status.setComplete();
return "redirect:user/list.html";
}
}
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(
dateFormat, false));
}
} |
Avez une idée sur l'origine du problème ?
J'ai vu sur un blog qu'il faut rajouter ceci
Code:
1 2 3
|
@RequestMapping("/**/user/*")
public class PersonController { ... |
mais ca ne marche tj pas :cry:
Merci par avance pour votre aide.