开发者

Can I have SEO friendly urls in Struts?

I want to have SEO friendly urls in my application, which will be built in java/j2ee using Struts (1/2).

I have 开发者_运维问答some classifications as follows

county/countryname
county/state/statename
county/state/locality/localitname

I guess above URLs will be seo friendly?

How can I have such URLs with Struts instead of something like /county='xyz' ?


use urlrewrite library, it will integrate nicely with most of the java web frameworks.

example from here:

In the following example requests for /world/usa/nyc will be transparently forwarded to /world.jsp?country=usa&city=nyc

<rule enabled="true">
   <from>^/world/([a-z]+)/([a-z]+)$</from>
   <to>/world.jsp?country=$1&amp;city=$2</to>
</rule>


You can use Apache mod_rewrite, it will convert your URLs like http://myapp.com/u/nishant/page/account/tab/3 to http://myapp.com?u=nishant&page=account&tab=3. So, your app don't need to worry about how URL structure.

Alternatively, you may use URLRewriteFilter, which is nothing but a cleverly written filter that need to the first filter of your application and all the requests should pass through this. It follows the same pattern rules as Apache mod_rewrite.


I don't think this can be done with Struts. You'll need Filters in order to achieve this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜