Bonjour,
je développe sous spring 4. Je n'arrive pas à mapper mes url aux controller
Voici un extrait de mon fichier web.xml
Voici un extrait de mon fichier spring xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <!-- Spring MVC --> <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>
Voici un extrait de mon controller
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix"> <value>/WEB-INF/pages/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> <context:component-scan base-package="orm,orm.impl,web.controller.impl,web.view" />
Le nom de mon application est tennisArc1600 et quand j'essaye via mon browser d'envoyer l'url http://localhost:8080/tennisArc1600/...re/getQuestion ou http://localhost:8080/unsecure/getQuestion
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
50
51
52
53
54
55
56
57 package web.controller.impl; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import service.CommonManagementService; import web.view.QuestionItem; import domain.Question; @Controller public class ComboController { private static final Logger LOGGER = LogManager.getLogger(); @Autowired @Qualifier("commonManagementService") private CommonManagementService commonManagementService; public CommonManagementService getCommonManagementService() { return this.commonManagementService; } @RequestMapping(value = "/unsecure/getQuestion", method = RequestMethod.GET) public ModelAndView getQuestion(ModelMap model) { LOGGER.info("debut methode getQuestion"); final List<QuestionItem> results = new ArrayList<QuestionItem>(); final List<Question> questions = this.commonManagementService.getQuestions(); for (final Question question : questions) { results.add(new QuestionItem(question.getQuestion(), question.getId().toString())); } final Map<String, Object> modelToPass = new HashMap<String, Object>(); model.put("items", results); LOGGER.info("fin methode getQuestion"); return new ModelAndView("jsonResultView", model); } public void setCommonManagementService( CommonManagementService commonManagementService) { this.commonManagementService = commonManagementService; } }
j'obtiens une erreur 404 la ressource demandée n'est pas disponible
Merci d'avance pour vos suggestions
Partager