Reputation: 279970
I have a struts ActionSupport
class that uses a Map<String, String>
to create <input>
elements in a jsp
where the name of the input is the key of the map. The map contains parameters (not fields) for a domain object I'm manipulating. I know that if you have a request parameter called, ex. username
, you could have a field in the class
private String username;
with a getter and setter and it would be populated for you. However, I can't know the name of the request parameters. Is there any way of injecting all remaining (those not mapped to fields) request parameters as a map (or other structure)?
The other solution I can think of is to use
ServletActionContext.getRequest();
get the request parameters, and compare them myself.
Upvotes: 1
Views: 2923
Reputation: 13821
You can implement the ParameterAware
interface and have the parameters injected into your action as a Map<String, String[]>
. However, It will give you all the request parameters, not only those it could populate directly in the action.
Upvotes: 3