我可以使用兩個jsps的請求映射嗎?Spring-MVC:兩個jsps合併成一個請求映射的控制器
我目前從一個控制器調用一個請求映射,但其中一個jsps似乎沒有被控制器捕獲。
兩個JSP中具有相同的形式,動作和相同的形式方法:
first.jsp是這樣的:
<form:form method="POST" action="/ShowroomNav/requestQuote" id="requestQuoteForm">
<input type="hidden" value=${product.productCode } name="productCodes" />
<input type="hidden" id="requestQuoteEmailAddress" name="requestQuoteEmailAddress" />
</form:form>
的second.jsp這個樣子:
<form:form method="POST" action="/ShowroomNav/requestQuote" id="requestQuoteForm">
<input type="hidden" id="requestQuoteEmailAddress" name="requestEmailAddress" />
<c:forEach var="product" items="${products}">
<input type="hidden" value=${product.productCode } name="productCodes" />
<div class="box">
<img
src="public/productImages/${product.productCode}/${product.productCode}A.jpg"
style="max-width: 100%"
onclick="productProfile('${product.productCode}')" /><br /> <label
class="name">${product.productName}</label>
</div>
</c:forEach>
</form:form>
兩個的人提交的功能通過javascript調用的:
$("#requestQuoteSubmitButton").one("click",function(){
$("#requestQuoteEmailAddress").val($("#requestQuoteEmailAddressModal").val());
alert($("#requestQuoteEmailAddress").val());
$("#requestQuoteForm").submit();
});
這是controller.java的樣子:
@RequestMapping(value = "/requestQuote", method = RequestMethod.POST) // or GET
public String requestQuote(@RequestParam("requestQuoteEmailAddress") String requestQuoteEmailAddress, @RequestParam("productCodes") String[] productCodes) {
System.out.println(">>>> requesting quotes >>>>");
for(int i=0; i<productCodes.length; i++) {
System.out.println(" Product Codes : " + productCodes[i]);
}
System.out.println("requestQuoteEmailAddress : " + requestQuoteEmailAddress);
System.out.println("<<<<< requesting quotes <<<<");
return "productSearch";
}
所以我不知道爲什麼second.jsp不能由控制器捕獲,因爲它總是顯示這個錯誤,當我嘗試提交。
HTTP Status 400 - The request sent by the client was syntactically incorrect.
有人可以幫忙嗎?
嗨@qingbo,感謝您的解答!我沒有真正看到這一點,這是相當混亂。謝謝。 – 2014-09-29 09:41:19