spring mvc怎么做302跳转

spring mvc怎么做302跳转

阅读 7k
2 个回答

我记得在web.xml中有配置这个的

        @ResponseStatus(value = HttpStatus.FOUND)
        public class MovedTemporarilyException extends RuntimeException {

            // ...
        }

        @RequestMapping(value = "/mypath.shtml", method = RequestMethod.GET)
        public ModelAndView pageHandler(@Valid MyForm form, BindingResult result, HttpServletRequest request,
                Locale locale) throws PageControllerException, InvalidPageContextException, ServiceException {

            if (someCondition){
                throw new MovedTemporarilyException();
            }
            else{
                // Do some stuff
            }
        }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进