在Java bean类中设置属性 [英] Set property in Java bean class

查看:77
本文介绍了在Java bean类中设置属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个文本字段名称为'empId'的文本字段,其值使用<jsp:setProperty>标签通过jsp页面设置为Bean类.

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

注意:empId在bean类中是int类型

当我编写以下代码时

<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")%>"/>

然后它不起作用 给出了JasperException异常

then it is not working gives the exception JasperException

推荐答案

使用EL表达式.

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

use ${param.empId} if you want to map request parameter.

<jsp:setProperty name="mybean" property="empId" value="${param.empId}"/>

PS:@Sheo,您必须显示异常堆栈跟踪.

PS: @Sheo you have to show exception stack trace.

这篇关于在Java bean类中设置属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆