2011-03-25 42 views
0

基于struts2 appfuse maven项目我试图建立我个人的HelloWorld struts2 maven项目。欢迎文件标记似乎被忽略

我在pom.xml,web.xml和struts.xml文件中简化了很多东西。因此,看起来<welcome-file-list><welcome-file>标签没有考虑到,当我点击http://localhost:8080/时,我的文件index.jsp未加载。 出现下一个错误消息: 没有为命名空间/和操作名称映射的操作。

(字“名称”之后,是一个空白空间)

任何意见将不胜感激。

web.xml中:

<filter> 
     <filter-name>struts2</filter-name> 
     <filter-class> 
      org.apache.struts2.dispatcher.FilterDispatcher 
      </filter-class> 
    </filter> 

    <filter-mapping> 
     <filter-name>struts2</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 

<listener> 
    <listener-class> 
     org.springframework.web.context.ContextLoaderListener 
    </listener-class> 
</listener> 

    <welcome-file-list> 
     <welcome-file>index.jsp</welcome-file> 
    </welcome-file-list> 

内的struts.xml:

<constant name="struts.devMode" value="true" /> 
<package name="default" namespace="/" extends="struts-default"> 
    <action name="Menu"> 
     <result>/menu/Menu.jsp</result> 
    </action> 
</package> 
+0

你可以只显示错误控制台输出 – 2011-03-25 11:03:27

+0

#消息:\t没有映射为命名空间/和动作名称动作。 堆栈跟踪 没有为命名空间/和操作名称映射的操作。 - [未知位置] com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178) – webmeiker 2011-03-25 11:45:30

+0

好的。这意味着您的映射中存在一些问题,以及您在何处调用您的操作。可以向我们展示jsp文件从你调用动作的位置“菜单” – 2011-03-25 11:48:50

回答

0

似乎Struts2的过滤器正在试图找到该名空 “” 或 “/” 路径的动作。因此欢迎名单将不会被达到。 “”&“/”在struts.xml中也没有条目。多数民众赞成在得到这个错误。

所以加在struts.xml中下面的项将解决这个问题..

<action name=""> <result>jsp file path</result></action> 
<action name="/"> <result>jsp file path</result></action>