将jsp元素值分配给struts2 textfield

时间:2013-03-28 17:28:59

标签: java jsp struts2

我正在实现更新用户详细信息的逻辑,因此我已经运行了hibernate查询和类申请人的所需对象现在我想要的是使用类Applicant对象并使用属性getApplicantId()并在Struts2 textfield中使用它< / p>

<%
String id="12"; // for not using static Id later i'll fetch Id from session.
UserData data=new UserData();
Applicant applicant=(Applicant)data.fetchUserData(id);
%>

现在我想在struts2文本域中使用JSP的ID,如

<s:textfield name="fName" value="<%=applicant.getApplicantId()%>"/> 

1 个答案:

答案 0 :(得分:0)

无法在Struts2标记中使用Scriptlet。我强烈建议将其移至行动中。作为解决方法,您可以使用字符串化值

<s:textfield name="fName"><%=applicant.getApplicantId()%></s:textfield>
相关问题