错误:java.lang.IllegalStateException:bean name';的BindingResult和普通目标对象都不存在;spcrId&x27;可用作请求属性
我试图构建简单的SpringMVC应用程序来实现CRUD操作。我正在查看以供参考 我的addSpcr.jsp文件是:错误:java.lang.IllegalStateException:bean name';的BindingResult和普通目标对象都不存在;spcrId&x27;可用作请求属性,java,spring,jsp,spring-mvc,Java,Spring,Jsp,Spring Mvc,我试图构建简单的SpringMVC应用程序来实现CRUD操作。我正在查看以供参考 我的addSpcr.jsp文件是: <form method="POST" action="/insert" modelAttribute="spcr"> <h2 style="text-align:center">SPCR Details</h2> <table style="width:100%" border="1px"> <tr> <
<form method="POST" action="/insert" modelAttribute="spcr">
<h2 style="text-align:center">SPCR Details</h2>
<table style="width:100%" border="1px">
<tr>
<td class="td_left">SPCR Id:</td>
<!-- <td class="td_right"><input type="text" id="spcrId" name="spcrId"/></td> -->
<td class="td_right"><form:input path="spcrId" /></td>
</tr>
<tr>
<td class="td_left">SPCR Header:</td>
<!-- <td class="td_right"><textarea id="spcrId" name="spcrId" rows="2" style="width:95%"> </textarea></td> -->
<td class="td_right"><form:input path="spcrHeader" /></td>
</tr>
它不会将jsp文件中的名称映射到pojo类中的字段名称。我不明白我在这里做错了什么
<form method="POST" action="/insert" modelAttribute="spcr">
将此更改为
<form method="POST" action="/insert" modelAttribute="addSpcr">
将此更改为
<form method="POST" action="/insert" modelAttribute="addSpcr">
您需要为
addSpcr.jsp
创建一个spcr
对象,因为在.jsp文件中有modeldattribute=“spcr”
,因此,当您加载控制器时,您需要一个与modalAttribute
值同名的模型您需要为addSpcr.jsp
创建一个spcr
对象,因为在.jsp文件中有modeldattribute=“spcr”
,因此,在加载控制器时,您需要一个与modalAttribute
值同名的模型我正在解释此错误。请理解您的错误并解决。
I am explain this error.please understand your mistack and solve.
1)**myjsppage.jsp**
<a href="insertaction">click</a>
2)Controller
@Requestmapping("/insertaction")
public String showpage(ModelMap model)
{
model.addAttribute("student",new student);
return "student"
}
3)student.jsp page
<form method="POST" action="/insert" modelAttribute="student">
//your code
1) **myjsppage.jsp**
2) 控制器
@请求映射(“/insertaction”)
公共字符串显示页(模型映射模型)
{
model.addAttribute(“学生”,新学生);
返回“学生”
}
3) student.jsp页面
//你的代码
model.addAttribute(“学生”,新学生);
modelAttribute=“学生”“
粗体表示必须是相同的名称。我正在解释此错误。请理解您的错误并解决。
1) **myjsppage.jsp**
2) 控制器
@请求映射(“/insertaction”)
公共字符串显示页(模型映射模型)
{
model.addAttribute(“学生”,新学生);
返回“学生”
}
3) student.jsp页面
//你的代码
model.addAttribute(“学生”,新学生);
modelAttribute=“学生”“
粗体表示必须是相同的名称。上面的错误消息清楚地表明“spcrId”bean没有exists@tnadeV它在我的pogo课上。您的表单标记将尝试与名为spcr的bean绑定,您是否有其他控制器?通过@RequestMapping(“/spcr”),上面的错误消息清楚地表明“spcrId”bean不存在exists@tnadeV它在我的pogo课上。您的表单标记将尝试与名为spcr的bean绑定,您是否有其他控制器?不管怎样,使用@RequestMapping(“/spcr”),您都需要使用modelAttribute=“addSpcr”,尝试从jspid零件中删除id=“spcrId”。因此您可以忽略它。在描述中添加了更多代码部分供您参考。请参考问题中给定的url。在地图中,我正在浏览下拉列表。无论如何,您将需要使用modelAttribute=“addSpcr”,尝试从jspid零件中删除id=“spcrId”。因此您可以忽略它。在描述中添加了更多代码部分供您参考。请参考问题中给定的url。在地图中,我正在浏览下拉列表。
<form method="POST" action="/insert" modelAttribute="spcr">
<form method="POST" action="/insert" modelAttribute="addSpcr">
I am explain this error.please understand your mistack and solve.
1)**myjsppage.jsp**
<a href="insertaction">click</a>
2)Controller
@Requestmapping("/insertaction")
public String showpage(ModelMap model)
{
model.addAttribute("student",new student);
return "student"
}
3)student.jsp page
<form method="POST" action="/insert" modelAttribute="student">
//your code