Set property in Java bean class

一个人想着一个人 提交于 2019-12-22 13:56:55

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!