【发布时间】: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