spring和jsp中的绑定错误,如果有人可以提供帮助,我将不胜感激。
我有适当的吸气剂和这些属性的设定者,
private int sydinv;
@NotNull(message="You must specify the inventory in Melbourne warehouse")
private int melinv;
当我在jsp文件中使用它们时,错误消息显示“Bean属性'sydinv'不可读或具有无效的getter方法:getter的返回类型是否与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 之外的所有属性,是否有人可以给我一些提示?干杯
答案 0 :(得分:0)
Bean属性'sydinv'不可读
此处您的sydinv
是用简单的方式编写的,但是您的getter方法指向SydInv
中的getSydInv()
写入。我认为您的getter
和setter
方法是错误的
将其更改为
setsydinv(int sydinv){this.sydinv = sydinv}
int getsydinv(){return sydinv}