我在Web上部署了一个应用程序。 Apache Tomcat版本是6.0.36
URL:www.sopmax.com
index.html(欢迎页面)将请求转发给sopmax.com/welcome。
我收到错误: 命名空间[/]和与上下文路径[]
关联的操作名称[welcome]没有映射下面是我的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>ShoppingShoe</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<context-param>
<param-name>tilesDefinitions</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<welcome-file-list>
<welcome-file>
index.html
</welcome-file>
</welcome-file-list>
</web-app>
struts.xml中
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="global" />
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<interceptors>
<interceptor name="secure" class="com.mss.interceptor.SecureStack">
</interceptor>
<interceptor-stack name="securestack">
<interceptor-ref name="secure"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="securestack"></default-interceptor-ref>
<action name="welcome*" class="com.mss.actions.Welcome" method="showHome">
<result type="tiles" name="success">welcome</result>
</action>
</package>
</struts>
我在com.mss.actions.Welcome类中有showHome方法,并且完美无缺。同一个应用程序在本地服务器上运行完美,但不在Web上运行。
我还设置了struts.devmode = true但是我得到的错误似乎是由tomcat而不是struts生成的。 请告诉我我错过了什么。
服务器:tomcat-apache 6.0.36 Java:我已经在1.7上开发了,很可能在网上他们有1.6
答案 0 :(得分:0)
Struts配置文件应该在classpath上,因此通常放在src
或resources
中的文件都用作源文件夹。部署后,它应该在WEB-INF/classes
。但是您的struts.xml
位置不同,配置未解析且在运行时不可用。