【发布时间】:2016-08-14 19:55:12
【问题描述】:
我已经为此苦苦挣扎了几个星期,我有下一个方法:
@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 注释中获取 id 值
我在 aplicationContext.xml
中有注释驱动我根本不使用注释,只是在那个方法中,我不知道控制器是否需要强制使用 @Controller 注释来使方法中的注释起作用,我不知道我缺少什么,在此先感谢各位。
【问题讨论】:
-
您是否在控制器级别设置了
@RequestMapping的value属性?是的,@Controller是控制器类所必需的。 -
我在 xml 中创建控制器,如果我将 @controller 放在类中是否重要?因为我得到下一个错误:
标签: spring controller