Spring控制器中是否可以有handleRequest函数以及参数注释?
我刚刚开始使用 spring 并在 NetBeans 中建立了一个简单的 spring 项目。默认情况下它似乎不使用注释。
在我的一个控制器中,我想处理表单上的不同点击。我看过一些解决方案,似乎添加参数检查可以工作:
@RequestMapping(params = "someAction")
public ModelAndView doSomeAction() {
但是看起来所有请求都会:
public class SetupController implements Controller {
@Override
public org.springframework.web.servlet.ModelAndView handleRequest(
HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception {
有没有一种方法可以在没有 RequestMapping 注释的情况下达到相同的效果?
I just started working with spring and set up a simple spring project in NetBeans. By default it doesn't seem to use annotations.
In one of my controllers I'd like to handle different clicks on the form. I have looked at some solutions and it seems like adding a parameter check could work:
@RequestMapping(params = "someAction")
public ModelAndView doSomeAction() {
However it looks like all of the requests are going to:
public class SetupController implements Controller {
@Override
public org.springframework.web.servlet.ModelAndView handleRequest(
HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception {
Is there a way I can achieve the same effect without RequestMapping annotation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您将旧的(实现控制器)样式与新的基于注释的样式混合在一起。
你不能(或者至少不应该)混合它们,至少在一门课上不能。
如果您使用 Spring 3.x,那么我强烈建议您使用基于注释的样式。
要启用基于注释的样式,您至少需要以下配置设置:
It seams that you mixed the old (implements Controller) style with the new one annotation based style.
You can't (or at least should not) mix them, at least not for one class.
If you use Spring 3.x then I strongly recommend to use the Annotation based style.
To enable the Annotation Based style, you need at least this configuration settings: