Can I have SEO friendly urls in Struts?

こ雲淡風輕ζ 提交于 2019-12-11 00:06:37

问题


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' ?


回答1:


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>



回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/5762498/can-i-have-seo-friendly-urls-in-struts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!