【发布时间】:2016-06-04 05:11:46
【问题描述】:
spring 和 jsp 中的绑定错误,如果有人可以提供帮助,我将不胜感激。
我有这些属性的正确 getter 和 setter,
private int sydinv;
@NotNull(message="You must specify the inventory in Melbourne warehouse")
private int melinv;
当我在 jsp 文件中使用它们时,错误消息说“Bean property 'sydinv' is not readable or has an invalid getter method: If the return type of the getter match the parameter type of the setter?”
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<form:form action="${pageContext.request.contextPath}/products/save" method = "post" commandName="product">
<label>Title
<form:input path="title" /> <form:errors path="title"/></label>
<br/>
<label> Description
<form:input type = "text" path= "description"/></label>
<br/>
<label>Price
<form:input path= "price" /><form:errors path="price"/></label>
<label>Image
<form:input path= "imageUrl" /><form:errors path="imageUrl"/></label>
<label>sydinv
<form:input path= "sydinv" /><form:errors path="sydinv"/></label>
<label>Inventory
<form:input path= "inventory" /><form:errors path="inventory"/></label>
<form:input type="hidden" path="productId"/>
<br/>
<input type = "submit" value = "Submit"/>
<br/>
<input type = "reset" />
</form:form>
这是我的控制器
@RequestMapping("/edit/{productId}")
public String edit(@PathVariable int productId, Model model){
//add your code here to find a product based on its id
//and put it in the model
Product product = pdao.getProductById(productId);
System.out.println("@@"+product.getSydInv()+"##"+product.getMelInv());
model.addAttribute("product", product);
return "product";
}
jsp文件可以读取除syd_inv之外的所有属性,谁能给我一些提示?干杯
【问题讨论】:
-
实际错误是什么?