I know Struts 2 make automatic mapping from request parameter to action class fields using param interceptor. But what if I want to map a parameter to an action field with different name. Suppose I have
<input type="text" name="username">
if I want to map this to the below field
private String realName;
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realNaame = realName;
}
How can I do this mapping. Can I use
realName = request.getParameter("username");
If so how can I get the request object in the action class? Also will it work in the JSP page with the OGNL expression username or realName ? Is there any other way in struts2 configuration to do this kind of mapping?
ServletRequestAwareinterface is used to get request object. - Aniket Kulkarni