Why welcome-file-list is not working if I remove struts2 .action extension?

前提是你 提交于 2019-11-30 21:07:06

I was having same issue in one of the application where i need to call an Action on page load in place of index.jsp or welcom.jsp in <welcome-page>.I did the following steps

Placed the following entry in my web.xml.

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

I created an empty file with name index in my web-app folder and finally placed the following entry in my struts.xml file

<action name="index" class="welcomeAction">
     <result>/ab.jsp</result>
 </action>

So in this case when i was hitting this URL www.myapp.com/myApp,its calling index action of Struts2 and i was able to do all init work for my welcome page.

I had same issue, but solved!!!!
If u use

<constant name="struts.action.extension" value=""/> 

in struts.xml
then put welcome file as

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

in web.xml
and give the action in struts.xml as follows

<package name="default" extends="struts-default">
    <action name="index.jsp">
        <result>WEB-INF/login.jsp</result>
    </action>
</package>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!