在 Java bean 类中设置属性

发布于 2024-12-23 13:17:12 字数 465 浏览 2 评论 0原文

我创建了一个文本字段名称“empId”,其值通过 jsp 页面使用 标签设置为 bean 类

note:empId 为 int 输入 bean class

当我编写以下代码时

<jsp:setProperty name="mybean" property="empId" value="empId"/>

它会正常工作 但是当我编写以下代码

<jsp:setProperty name="mybean" property="empId" value="<%=request.getParameter("empId")%>"/>

时它不起作用 给出异常 JasperException

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴骨ら 2024-12-30 13:17:12

使用EL表达式。

如果要映射请求参数,请使用 ${param.empId}

PS:@Sheo 你必须显示异常堆栈跟踪。

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.

守不住的情 2024-12-30 13:17:12
String employeeID = (String) request.getParameter("employeeID");

<jsp:setProperty value="<%=employeeID%>" ..../>

希望它有效:)

........./

String employeeID = (String) request.getParameter("employeeID");

<jsp:setProperty value="<%=employeeID%>" ..../>

Hope it works :)

........../

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文