关于Spring MVC 路径映射的问题
配置:
- XML code
<context:component-scan base-package="com.mtea.mis.controller" /><bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"><property name="caseSensitive" value="true" /></bean><bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"p:prefix="/WEB-INF/view/" p:suffix=".jsp" p:viewClass="org.springframework.web.servlet.view.JstlView" />
代码:
- Java code
@Controllerpublic class UserTypeController {@Resourceprivate UserTypeService userTypeService;@RequestMappingpublic List<UserType> list() {return userTypeService.geAll();}@RequestMapping("/input/{id}")public String input(@PathVariable("id") int id,Model model) {model.addAttribute(userTypeService.getByAutoId(id));return "userType/input";}
测试:
1.http://localhost:10123/userType/list.do 没有问题
2.http://localhost:10123/userType/input/3.do 出错:
2011-9-22 20:37:11 org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping found for HTTP request with URI [/userType/input/3.do] in DispatcherServlet with name 'SpringMVC'
请问何故,请激扬文字! 盼君多复!
[解决办法]