ここに私の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にリダイレクトされるはずですが、それが得られません。「アクションのexecute()を入力中」と出力しています。これは、Action クラスに入っていることを意味します。私が何か間違ったことをしている場合は、私を修正してください。