Spring MVC错误 - 请求处理失败;嵌套异常是java.lang.IllegalStateException

时间:2017-04-25 03:12:42

标签: java android spring spring-mvc

我通过XML解析继续安装Android Studio - Spring,出现以下错误:

  
    

HTTP状态500 - 请求处理失败;嵌套异常是java.lang.IllegalStateException:一个Errors / BindingResult参数是     期望在模型属性之后立即声明,     @RequestBody或它们适用的@RequestPart参数:.....     。 。 。春天是

  

代码

@RequestMapping(value = "/boardToMyXml")
@ResponseBody
public XmlDataList MyXml( Errors errors,HttpSession session, HttpServletRequest request, 
            Model model, HttpServletResponse response) {
        String id = request.getParameter("id");
        String pw = request.getParameter("pw");
        AuthInfo authInfo = authService.authenticate(id, pw);
        int userNum =authInfo.getUserNum();
        model.addAttribute("id", id);
        model.addAttribute("pw", pw);
        model.addAttribute("userNum", userNum);
        List<Data> listm = boardDao.xmlMyBoardList(userNum);
        System.out.println(listm);

        return new XmlDataList(listm);
    }

1 个答案:

答案 0 :(得分:0)

我认为当Errors errors@Valid注释用于方法签名中的任何其他参数时,{!1}}应作为参数添加。请看下面的stackoverflow答案

An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments

Errors/BindingResult argument is expected