我有一个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()
?
答案 0 :(得分:-1)
使用:
@RequestMapping(value={"action1","action2","action3"},
method = RequestMethod.POST)