当前位置: 首页 > 知识库问答 >
问题:

java.lang.IllegalStateException Spring MVC

阚小云
2023-03-14

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

无法运行它。

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

for bean名称“unixmodel11”可作为请求属性使用

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";

   }

}

无数的麻烦

<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>

包com.myriad.ihc.bean;

公共类UnixModel{

专用字符串主机;

专用字符串用户名;

专用整数端口;

return host;

}

public void setHost(字符串主机){

this.host = host;

}

return userName;
this.userName = userName;

公共整数getPort(){

return port;

}

public void setPort(整数端口){

this.port = port;

}

}

共有1个答案

计承德
2023-03-14

我还在jsp页面中添加了commandName作为

Form:Form method=“Post”action=“loginunixs”commandname=“unixmodel11”

 类似资料:

相关问答

相关文章

相关阅读