作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近一直在阅读 Spring 3.2,现在我正在尝试使用 Spring 2.5 编写以下代码。根据我的阅读,这应该意味着它应该映射 profile/tags/me
。然而事实并非如此。它只是抛出一个 No mapping found for HTTP request with URI ...
。代码有什么问题,或者 Spring 2.5 的工作方式与 Spring 3 不同?
使用 Spring 2.5 时的问题
@Controller
@RequestMapping("/profile/tags")
public class ProfileController { ... }
这是 ProfileController 类中的方法:
@RequestMapping(value = "/me", method = RequestMethod.GET)
public String show(@RequestParam final long id, final ModelMap model) { ... }
最佳答案
根据 Spring documentation ,我想你缺少接收请求参数所需的配置,如果你想接收这个请求参数:
@RequestMapping(value = "/me/{id}", method = RequestMethod.GET)
public String show(@RequestParam("id") final long id, final ModelMap model) { ... }
或者您应该删除 RequestParam
。
此外,由于您使用的是 Spring 2.5,因此请确保您已按预期方式配置了 DispatcherServlet
;栏目 13.11 ,第 1、2 和 3 小节。总结:
希望这对您有所帮助。
关于java - @RequestMapping 不适用于 Spring 2.5 中的类型和方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15876834/
我是一名优秀的程序员,十分优秀!