How to pass parameters in struts2?

In Struts2, parameters can be passed in two ways: through URL parameters and form parameters.

  1. what is the URL of the website?
  2. Please provide me with your final decision.

For example, creating a URL with parameters:

<s:url var="myUrl" action="myAction">
    <s:param name="param1" value="value1" />
    <s:param name="param2" value="value2" />
</s:url>

Then use that URL in the or tag.

<s:a href="%{myUrl}">Link</s:a>
<s:submit value="Submit" action="%{myUrl}" />

In Action, you can receive passed values by defining corresponding parameters.

private String param1;
private String param2;

// Getter and setter methods

public String execute() {
    // 使用接收到的参数进行业务处理
    return "success";
}
  1. Enter your name: