问题
I have created a from which have a text field name 'empId' whose value is set into a bean class through a jsp page using <jsp:setProperty> tag
note:empId is of int type in bean class
when i write the following code
<jsp:setProperty name="mybean" property="empId" value="empId"/>
It will work fine but when i write the following code
<jsp:setProperty name="mybean" property="empId" value="<%=request.getParameter("empId")%>"/>
then it is not working gives the exception JasperException
回答1:
Use EL expression.
use ${param.empId} if you want to map request parameter.
<jsp:setProperty name="mybean" property="empId" value="${param.empId}"/>
PS: @Sheo you have to show exception stack trace.
回答2:
String employeeID = (String) request.getParameter("employeeID");
<jsp:setProperty value="<%=employeeID%>" ..../>
Hope it works :)
........../
来源:https://stackoverflow.com/questions/8666182/set-property-in-java-bean-class