Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1506
  • Last Modified:

How to remove .action extension from url in Struts2?

I would like to remove action extension so I could use "/login" instead of "/login.action". I tried to use:

struts.action.extension=action,,

but this doesn't work.
0
majkic
Asked:
majkic
  • 2
1 Solution
 
boonlengCommented:
You can use URLRewriteFilter http://raibledesigns.com/rd/entry/extensionless_urls_in_java_web to produce extensionless URL.

If you are using Struts 2.0, you can add SmartURLs plugin http://cwiki.apache.org/S2PLUGINS/smarturls-plugin.html to remove the URL extension. Currently SmartURLs does not work for Struts 2.1.
0
 
majkicAuthor Commented:
Actually I'm using Struts 2.1.2, so second solution doesn't work for me. Considering the first one, I'm not quite sure what I need to do to rewrite url. I'm using Spring framework and this probably helps, but I don't see how to setup filter mentioned in this article.
0
 
boonlengCommented:
It doesnt matter whether using Spring or not, it's a servlet filter.
http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.1/index.html
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now