• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts2 default extension change issue

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a following package tag in my struts.xml to redirect the root URL to my home.jsp. And I am not using web.xml <welcome-file-list>


<package name="default" namespace="/" extends="struts-default">
<action name="" class="actions.home.Home" method="execute">
<result name="success">/views/home.jsp</result>
</action>
</package>


So this is working well and opening the home.jsp page when I run the application.

Then I wanted to change the .action extension to .html using following line in the struts.xml

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

Now this is working for all my url except for the root redirection. I mean when I deply and run , it gives me page not found message in the browser and I can type and view other pages with .html extension.

Please help me modify my package tag ablove.



Regards

jklanka
 
Ranch Hand
Posts: 88
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is happening because, default behaviour of struts 2 is lookup for an entry in struts.xml when,
1. requested url has extension .action
2. or there is no extension at all.

Since request made on context root does not have any extension your page opens.
But, now you enforsed struts to lookup only when extension is .html hence its not working.

Do you have any good reason for not to use web.xml's welome-file-list
 
muthulingam Jayakanthan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Thanks for the reply.

Without the line '<constant name="struts.action.extension" value="html"/>' I put the welcome list as below in web.xml

<welcome-file-list>
<welcome-file>Home.action</welcome-file>
</welcome-file-list>


Then in struts.xml I placed the following lines

<package name="default" namespace="/" extends="struts-default">
<action name="*" class="actions.home.Home" method="execute">
<result name="success">/views/home.jsp</result>
</action>
</package>


Now it is working fine.


But the issue is :-

If I put the following lines in struts.xml, then home page is not loading
<constant name="struts.action.extension" value="html"/>

Please help me what other modification I have to do. I need to replace my .action extension to .html

Regards

jklanka
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic