繁体   English   中英

春天的@requestparam无法正常工作

[英]@requestparam in spring is not working

我已经为此苦苦挣扎了两周,我有了下一个方法:

@RequestMapping( method = RequestMethod.GET )
    public ModelAndView update(
            HttpServletRequest request, 
            HttpServletResponse response,
    @RequestParam( value = "id", required = true ) String id ) throws Exception 
    {
        model = new ModelAndView( "/jspadmin/game/update" );

        getLog().error( "::: valor del string: " + request.getParameter( "id" ) );
        getLog().error( "::: valor del string: de ruta" + id );
     }

这个代码是MultiActionController的里面,但我不能获得价值从@RequestParam anotation的ID

aplicationContext.xml我已经anotation驱动

我根本不使用注释,只是在那种方法中,我不知道控制器是否需要强制使用@Controller注释来使方法中的那些注释生效,我不知道我缺少了什么,谢谢大家。

尝试使用@Controller批注:

@Controller
@RequestMapping("/rootUrl")
public class MyController...

和动作:

@RequestMapping(value="/url", method = RequestMethod.GET )
public String update(@RequestParam...

请使用以下代码,只需在请求映射中为某些模式添加值

@RequestMapping(value = "/save", method = RequestMethod.GET)
public ModelAndView update(HttpServletRequest request, HttpServletResponse response,
        @RequestParam(value = "id", required = true) String id) throws Exception {
    System.out.println("Inside Save id is " + id);
    return new ModelAndView("index");
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM