Pig*_*ras 5 java struts2 action-mapping
如果我.action在Struts2应用程序中删除扩展,我有一个问题.我把它放在我的struts.xml:
<constant
name="struts.action.extension"
value="" />
Run Code Online (Sandbox Code Playgroud)
除索引页面外,应用程序正常工作.我有web.xml这个:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
当我访问时http://localhost/myApp/,我收到以下错误:
There is no Action mapped for namespace [/] and
action name [index.jsp] associated with context path [/myApp].
- [unknown location]
Run Code Online (Sandbox Code Playgroud)
但是,如果我访问http://localhost/myApp/fooAction,我没有得到任何错误,并且工作完美.
如果我更改非空扩展的扩展名(例如"html"),如果我访问,我会完全看到索引页面http://localhost/myApp/.
那么,我正在做的事情有什么不对吗?删除扩展程序时,为什么会出现此错误?有没有可行的方法没有得到它?
编辑:如果我<welcome-page>在错误中放置一个动作如下:
There is no Action mapped for namespace [/] and action name []
associated with context path [/myApp].
Run Code Online (Sandbox Code Playgroud)
我在其中一个应用程序中遇到同样的问题,我需要在页面加载时调用Action代替index.jsp或welcom.jsp在<welcome-page>.我做了以下步骤
在我的web.xml中放置以下条目.
<welcome-file-list>
<welcome-file>index</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
我index在我的web-app文件夹中创建了一个带有名称的空文件,最后将以下条目放在我的struts.xml文件中
<action name="index" class="welcomeAction">
<result>/ab.jsp</result>
</action>
Run Code Online (Sandbox Code Playgroud)
所以在这种情况下,当我点击这个URL时www.myapp.com/myApp,它的Struts2和我的调用索引操作能够为我的欢迎页面完成所有初始化工作.
| 归档时间: |
|
| 查看次数: |
6568 次 |
| 最近记录: |