Bonjour tout le monde,
je travaille sur un exemple spring MVC + apache tiles (je suis ce tuto : http://viralpatel.net/blogs/spring-3...ample-eclipse/).
voilà le code de mon controleur :
voilà le code de tiles_defs.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 @Controller @RequestMapping("/contact") @SessionAttributes public class ContactController { //methode permettant d'ajouter un nouveau contact @RequestMapping(value="/addContacts", method=RequestMethod.POST) public String addContact(@ModelAttribute("contact") Contact contact, Model model, BindingResult result){ String message = "First Name: " + contact.getFirstName() + ", Last Name: " + contact.getLastName(); model.addAttribute("message", message); return "home"; } //methode permettant d'afficher le formulaire d'ajout de contact @RequestMapping("/show") public ModelAndView showContacts(){ ModelAndView model = new ModelAndView("contacts", "command", new Contact()); return model; } }
voilà le code de fichier de configuration :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN" "http://tiles.apache.org/dtds/tiles-config_2_0.dtd"> <tiles-definitions> <definition name="baseDefinition" template="/WEB-INF/views/layout.jsp"> <put-attribute name="title" value="" /> <put-attribute name="header" value="/WEB-INF/views/header.jsp" /> <put-attribute name="menu" value="/WEB-INF/views/menu.jsp" /> <put-attribute name="body" value="" /> <put-attribute name="footer" value="/WEB-INF/views/footer.jsp" /> </definition> <definition name="contact" extends="baseDefinition"> <put-attribute name="title" value="Contact Manager" /> <put-attribute name="body" value="/WEB-INF/views/contacts.jsp" /> </definition> <definition name="welcome" extends="baseDefinition"> <put-attribute name="title" value="Welcome" /> <put-attribute name="body" value="/WEB-INF/views/home.jsp" /> </definition> </tiles-definitions>
En essayant de lancer mon exemple (en tapant l'url http://localhost:8080/controllers/contact/show), j'ai l'erreur 404 : La ressource demandée n''est pas disponible.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --> <!-- Enables the Spring MVC @Controller programming model --> <annotation-driven /> <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --> <resources mapping="/resources/**" location="/resources/" /> <!-- integrates tiles in web applications using spring --> <beans:bean name="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <beans:property name="viewClass"> <beans:value> org.springframework.web.servlet.view.tiles2.TilesView </beans:value> </beans:property> </beans:bean> <beans:bean name="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"> <beans:property name="definitions"> <beans:list> <beans:value>/WEB-INF/tiles_defs.xml</beans:value> </beans:list> </beans:property> </beans:bean> <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --> <!-- <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> --> <context:component-scan base-package="com.example.*" /> </beans:beans>
je ne vois pas pourquoi ?!!!
Merci pour votre aide.








Répondre avec citation
Partager