我有一个 JSP 说 myPage.jsp
在jsp中我有两个div
每个 div 包含一种形式,如下所示:
分区 A:
<div class="validation-box">
<form:form id="compnay-detail" method="post" action="companySave.do" commandName="company">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="col"><label>Address Type</label> <form:input type="text" path="addressType" class="textbox" name="addressType" id="addType" maxlength="20" />
</td>
<td class="col"><label>Street</label> <form:input path="street"
class="textbox" name="street" id="street" maxlength="50" />
</td>
</tr>
<tr>
<td colspan="3" class="no-padding">
<div class="button-pannel margin-top">
<span class="lhscrv"> <span class="rhscrv"> <input type="submit" class="bttn" id="saveAddress" value="Save" />
</span>
</span> <span class="lhscrv"> <span class="rhscrv"> <input
type="button" class="bttn" id="reset" value="Reset" />
</span>
</span> <span class="lhscrv"> <span class="rhscrv"> <input
type="button" class="bttn" id="cancel" value="Cancel" />
</span>
</span>
</td>
</tr>
</table>
</form:form>
</div>
分区 B:
<div class="validation-box">
<form:form id="compnayAddDetail" method="post" action="test.do" commandName="address">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="col"><label>Address Type</label> <form:input type="text" path="addressType" class="textbox" name="addressType" id="addType" maxlength="20" />
</td>
<td class="col"><label>Street</label> <form:input path="street"
class="textbox" name="street" id="street" maxlength="50" />
</td>
</tr>
<tr>
<td colspan="3" class="no-padding">
<div class="button-pannel margin-top">
<span class="lhscrv"> <span class="rhscrv"> <input type="submit" class="bttn" id="saveAddress" value="Save" />
</span>
</span> <span class="lhscrv"> <span class="rhscrv"> <input
type="button" class="bttn" id="reset" value="Reset" />
</span>
</span> <span class="lhscrv"> <span class="rhscrv"> <input
type="button" class="bttn" id="cancel" value="Cancel" />
</span>
</span>
</td>
</tr>
</table>
</form:form>
</div>
我的控制器类:
@RequestMapping("/companySave.do")
public String saveCompany(Map<String, Object> map, @ModelAttribute("company")
Company company,@ModelAttribute("address")
CompanyAddress address, BindingResult result)
{
//...... code.......
return "redirect:/companyAddressPage/"+company.getId()+".do";
}
@RequestMapping("/companyAddressPage/{id}.do")
public String companyAddressPage(@PathVariable("id") long id,Map<String, Object> map, @ModelAttribute("company")
Company company,@ModelAttribute("address")
CompanyAddress address, BindingResult result)
{ //...... code.......
return "myPage";
}
@RequestMapping("/test.do")
public String saveAddressCompany(Map<String, Object> map, @ModelAttribute("company")
Company company,@ModelAttribute("address")
CompanyAddress address, BindingResult result)
{ //...... code.......
return "myPage";
}
目标:
在提交 div A 中存在的第一个表单后,我想启用包含另一个表单的 div B。
问题 :
第一个表单正确提交,但是当我单击第二个表单的提交按钮时,它抛出异常(甚至没有调用操作)
例外 :
无法将值测试从“java.lang.String”类型转换为“long”类型;嵌套异常是 java.lang.NumberFormatException: For input string: "test"] with root cause
任何想法....???
提前致谢...!!!