关于Spring MVC 路径映射的问题

macrotea-cn 2011-09-22 08:38:24
配置:


<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" />


代码:

@Controller
public class UserTypeController {

@Resource
private UserTypeService userTypeService;

@RequestMapping
public 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'


请问何故,请激扬文字! 盼君多复!
...全文
448 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
magong 2011-09-23
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 myxiao7 的回复:]

依旧提示:
警告: No mapping found for HTTP request with URI [/userType/input/3.do] in DispatcherServlet with name 'SpringMVC'
[/Quote]
请贴完整的代码。
magong 2011-09-23
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 myxiao7 的回复:]

依旧提示:
警告: No mapping found for HTTP request with URI [/userType/input/3.do] in DispatcherServlet with name 'SpringMVC'
[/Quote]
请贴完整的代码。
magong 2011-09-23
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 myxiao7 的回复:]

依旧提示:
警告: No mapping found for HTTP request with URI [/userType/input/3.do] in DispatcherServlet with name 'SpringMVC'
[/Quote]
请贴完整的代码。
macrotea-cn 2011-09-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 jayyounger 的回复:]

这是警告,不算错误
[/Quote]

虽非错误,然页面不能正确显示,因此心生疑虑,不得排解.盼君多助
macrotea-cn 2011-09-22
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 magong 的回复:]

已贴的代码没什么问题。
楼主可以检查下是否漏配了 <annotation-driven />
[/Quote]

1.我按照你说的操作了: 添加<mvc:annotation-driven />

2.然而问题依旧,当我访问:
http://localhost:10123/userType/input/3.do

依旧提示:
警告: No mapping found for HTTP request with URI [/userType/input/3.do] in DispatcherServlet with name 'SpringMVC'

从而导致tomcat提示:
HTTP Status 404 -

因此不能正确显示页面,不知道具体原因是何故!若方便请深入赐教!
magong 2011-09-22
  • 打赏
  • 举报
回复
已贴的代码没什么问题。
楼主可以检查下是否漏配了 <annotation-driven />
原来缘来 2011-09-22
  • 打赏
  • 举报
回复
这是警告,不算错误

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧