我有一个使用 struts 2 的 Web 应用程序,它可以通过在 URL 中逐字键入来访问操作
localhost/project/index.action
但如果不明确输入它,它不会重定向到这个默认操作。
localhost/project/
给出错误
Error 404: SRVE0190E: File not found: {0}
我假设找不到该文件,因为我没有正确配置某些东西。
任何人都可以为我指出正确的方向,以便使用 Struts 2 获得这种行为吗?
这里的每个请求是我的 struts.xml 和 web.xml
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Doc Parser</display-name>
<filter>
<filter-name>struts-prepare</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
</filter>
<filter>
<filter-name>struts-execute</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
</filter>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-prepare</filter-name>
<url-pattern>*.action</url-pattern>
<url-pattern>/struts/*</url-pattern>
<url-pattern>/</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>*.action</url-pattern>
<url-pattern>/struts/*</url-pattern>
<url-pattern>/</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts-execute</filter-name>
<url-pattern>*.action</url-pattern>
<url-pattern>/struts/*</url-pattern>
<url-pattern>/</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class>
</listener>
<servlet>
<servlet-name>sitemesh-freemarker</servlet-name>
<servlet-class>org.apache.struts2.sitemesh.FreemarkerDecoratorServlet</servlet-class>
<init-param>
<param-name>default_encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>sitemesh-velocity</servlet-name>
<servlet-class>org.apache.struts2.sitemesh.VelocityDecoratorServlet</servlet-class>
<init-param>
<param-name>default_encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sitemesh-freemarker</servlet-name>
<url-pattern>*.ftl</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>sitemesh-velocity</servlet-name>
<url-pattern>*.vm</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
信任.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<constant name="struts.freemarker.templatesCache" value="true" />
<constant name="site.framework.roles"
value="
free => http://security.site.com/service/mwstutorial/getItems,
loggedIn => http://security.site.com/service/mwstutorial/setItems" />
<package name="blank" extends="default">
</package>