我一直在努力争取这几周,我有下一个方法:
@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我根本不使用anotations,只是在那个方法中,我不知道控制器是否需要@Controller anotation强制使工作方法中的那些anotations,我不知道我缺少什么,感谢提前的家伙。
答案 0 :(得分:1)
尝试使用@Controller注释:
@Controller
@RequestMapping("/rootUrl")
public class MyController...
和行动:
@RequestMapping(value="/url", method = RequestMethod.GET )
public String update(@RequestParam...
答案 1 :(得分:0)
请使用以下代码,只需在请求映射中为某些模式添加值
@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");
}