2016-08-14 65 views
0

我已经与现在挣扎了几个星期,我有一个方法:@RequestParam春不工作

@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,但我不能获得ID从@RequestParam anotation值

我已经anotation在aplicationContext.xml

即时不使用anotations所有,只是在该方法中,我不知道如果T驱动他控制器需要一个@Controller anotation强制性的使工作中的方法,我不知道什么即时通讯失踪,感谢提前家伙工作。

+1

你有在控制器级设置了@ RequestMapping的'value'属性?是的,在控制器类上需要'@ Controller'。 –

+0

我在xml中创建控制器,如果我把@controller放在类中,这很重要吗?因为我得到下一个错误: –

回答

1

尝试用注解@Controller:

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

和行动:

@RequestMapping(value="/url", method = RequestMethod.GET) 
public String update(@RequestParam... 
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"); 
} 
+1

给出的解决方案可能工作请试用 – Dilip