Hi I am running a spring MVC app but due to java.lang.IllegalStateException I am
not able to run it.
Here is the Exception
java.lang.IllegalStateException: Neither BindingResult nor plain target object
for bean name 'unixModel11' available as request attribute
For your reference some class and JSP page
Controller:
@Controller
public class 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) {
model.addAttribute("userName", unixModel.getUserName());
model.addAttribute("host", unixModel.getHost());
model.addAttribute("port", unixModel.getPort());
return "result";
}
}
index.jsp
Myriad Trouble Shoot
Trouble Shoot Application
<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:
package com.myriad.ihc.bean;
public class UnixModel {
private String host;
private String userName;
private Integer port;
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
}