这是我的 index.jsp 文件:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
  <head>
    <title>HOME</title>
  </head>
  <body>
    <s:action name="getUrl"></s:action>
  </body>
</html>
这是我的 struts.xml:
<struts>
  <action name="getUrl" class="UrlAction">
    <result name="redirect" type="redirect">${url}</result>
  </action>
</struts>
这是我的动作课:
public class UrlAction extends ActionSupport {
  private String url;
  public void setUrl(String url) {
    this.url = url;
  }
  public String getUrl(){
    return url;
  }
  public String execute() throws Exception {
    System.out.println("Entering execute() of Action");
    url = "https://www.google.com/";
    return "redirect";
  }
}
因此,当我运行 index.jsp 时,它应该将我重定向到https://www.google.com,但我不明白。它正在打印“输入操作的执行()”。这意味着它正在进入 Action 类。如果我做错了什么,请纠正我。