当我输入我的根网址(fail.jsp
)时,我想重定向到localhost:8081/
。这是我的java类Root:
@Namespaces(value={@Namespace("/User"), @Namespace("/")})
@Result(location="/fail.jsp")
@Actions(value={@Action(""), @Action("home")})
public class Root {
public String execute() throws Exception {
return "success";
}
}
目前,它将我重定向到index.jsp
。大多数在线教程都提到了web.xml
,但有些人告诉我它与web.xml
无关。所以我很困惑。愿有人帮助我理解我所缺少的东西吗?
这是我的应用树:
答案 0 :(得分:1)
发现我需要.xml
设置或正确的Spring& Struts集成以摆脱所有xml。
Here是第二个选项的教程
答案 1 :(得分:0)
您在网络根文件夹中有index.jsp
。如果您要求显示此文件夹,并且网络服务器发现该文件夹中有index.jsp
,则会重定向到index.jsp
。此代码来自Tomcat的web.xml
:
<!-- ==================== Default Welcome File List ===================== -->
<!-- When a request URI refers to a directory, the default servlet looks -->
<!-- for a "welcome file" within that directory and, if present, to the -->
<!-- corresponding resource URI for display. -->
<!-- If no welcome files are present, the default servlet either serves a -->
<!-- directory listing (see default servlet configuration on how to -->
<!-- customize) or returns a 404 status, depending on the value of the -->
<!-- listings setting. -->
<!-- -->
<!-- If you define welcome files in your own application's web.xml -->
<!-- deployment descriptor, that list *replaces* the list configured -->
<!-- here, so be sure to include any of the default values that you wish -->
<!-- to use within your application. -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
如果从根文件夹中删除index.jsp
,则如果代码与操作的映射正确,则代码可能会起作用。您可能还会发现此问题Can Struts 2 First Page come through the engine instead of listing it in 并回答对您有用。