简体   繁体   中英

Assigning jsp element value to struts2 textfield

I am implementing logic for updating user details so for that i have run hibernate query and desired object of class Applicants now what I want is to use class Applicant object and use property getApplicantId() and use it in Struts2 textfield

<%
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);
%>

Now i want to use JSP's ID in struts2 textfield like

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

Scriptlets can't be used in the Struts2 tags. And I strongly recommend to move it to the action. As a workaround you may use a stringified value

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM