限制MultiActionController操作的方法

时间:2014-07-11 02:19:53

标签: java spring spring-mvc

我有一个MultiActionController,如果使用POST方法,我只希望可以访问该动作。

public class MyController extends MultiActionController {

  public ModelAndView myAction(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    // I don't want to hit this code unless POST was used
  }

}

有没有办法通过注释实现这一点,还是我不能检查request.getMethod()

1 个答案:

答案 0 :(得分:-1)

使用:

@RequestMapping(value={"action1","action2","action3"}, 
    method = RequestMethod.POST)