How to get the param which content-type is x-www-form-urlencoded in Struts 2

569 Views Asked by At

The request is like this: enter image description here

In server,I have a bean like this:

@Data
public class TechInfo {
    private int shopID;    
    private String name;   
    private int experience;   
    TechnicianTitleInfo technicianTitleInfo;  
    private String skill;
}

How can I get the request params in Struts2 ?

I've declared a TechInfo in my action, but its value is null after Struts2 parsed it.

The action is like this:

public class AjaxAction{

    @Getter @Setter private TechInfo techInfo;

    protected void jsonExecute() throws Exception {
      //need the techInfo
    }
}
2

There are 2 best solutions below

0
On

The correct parameter format is the one using the Dot Notation:

techInfo.picID
techInfo.name
techInfo.technicianTitleInfo.titleId

and so on.

0
On

How to get the param which content-type is x-www-form-urlencoded

Struts2 is using request.getParameterMap().

I've declared a TechInfo in my action, but its value is null after Struts2 parsed it.

The value is null because TechInfo isn't bound to the action class variable. Request parameter name should be the same as variable name techInfo.