【问题标题】:java.lang.IllegalStateException Spring MVCjava.lang.IllegalStateException Spring MVC
【发布时间】:2016-08-05 21:19:47
【问题描述】:

嗨,我正在运行一个 Spring MVC 应用程序,但由于 java.lang.IllegalStateException 我是

无法运行。

这里是例外

java.lang.IllegalStateException: 既不是 BindingResult 也不是普通目标对象

对于可用作请求属性的 bean 名称“unixModel11”

一些类和 JSP 页面供您参考

控制器:

@控制器

公共类TroubleController {

@RequestMapping(value = "/index", method = RequestMethod.GET)

public ModelAndView welcomePage(Model model) {

    return new ModelAndView("index","unixModel11", new UnixModel());  


}
    @RequestMapping(value = "/loginUNIX", method = RequestMethod.POST)

   public String checkUnix(@ModelAttribute("unixModel11")UnixModel 

unixModel,ModelMap 模型){

model.addAttribute("userName", unixModel.getUserName());

      model.addAttribute("host", unixModel.getHost());

      model.addAttribute("port", unixModel.getPort());

      return "result";

   }

}

index.jsp

各种疑难杂症

疑难解答应用

<tr>

    <td><form:label path="host">Host Name</form:label></td>

    <td><form:input path="host" /></td>

</tr>

<tr>

    <td><form:label path="userName">User Name</form:label></td>

    <td><form:input path="userName" /></td>

</tr>

<tr>

    <td><form:label path="port">Port Number</form:label></td>

    <td><form:input path="port" /></td>

</tr>

<tr>

    <td colspan="2">

        <input type="submit" value="Submit"/>

    </td>

</tr>

UnixModel.java:

包 com.myriad.ihc.bean;

公共类 UnixModel {

私有字符串主机;

私有字符串用户名;

私有整数端口;

公共字符串 getHost() {

return host;

}

public void setHost(String host) {

this.host = host;

}

公共字符串 getUserName() {

return userName;

}

public void setUserName(String userName) {

this.userName = userName;

}

公共整数 getPort() {

return port;

}

public void setPort(整数端口) {

this.port = port;

}

}

【问题讨论】:

    标签: spring-mvc


    【解决方案1】:

    我也在jsp页面中添加了commandName

    form:form method="POST" action="loginUNIXs" commandName="unixModel11"

    【讨论】:

      猜你喜欢
      • 2018-06-26
      • 2017-09-21
      • 2020-12-23
      • 2020-01-09
      • 1970-01-01
      • 2015-06-12
      • 2017-07-13
      • 2012-10-31
      • 2018-11-12
      相关资源
      最近更新 更多