如何在 STRUTS 上重写 SEO 友好的 URL?

发布于 2024-08-09 09:25:10 字数 364 浏览 6 评论 0原文

我们有一个使用 Struts 框架使用 Java 进行编码的网站。该网站的 URL 不利于搜索引擎优化。全部都是像下面这样的

../buyerApplication.do&companyId=2323

现在我们想让这些 URL SEO 友好,我搜索并找到了这些解决方案:

  • tuckey.org/urlrewrite :但我不依赖这个系统。
  • 添加 标题“&”后链接结束例如 “../newsId=33233&城市中的艺术是否等于城市中的艺术” :在这个解决方案中我不确定 效果很好。

我正在等待您的建议来最好地解决这个问题。

We have a website which is coded Java with Struts Framework. The WebSite's Urls are not seo friendly. All of them are like below

../buyerApplication.do&companyId=2323

Now We want to make these URLs SEO friendly and I searched and found these solutions:

  • tuckey.org/urlrewrite : but i don't rely on this system.
  • adding
    title end of link after '&' such as
    "../newsId=33233&does-art-in-the-city-equal-art-for-the-city"
    : In this solution I am not sure it
    works well.

I am waiting your sugestions to solve this problem best.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尐偏执 2024-08-16 09:25:10

我实际上使用了 URLRewriter (http://tuckey.org/urlrewrite/),您在原始文件中引用了它问题。设置非常简单,完美满足了我的需求。

I actually used URLRewriter (http://tuckey.org/urlrewrite/), which you referenced in your original question. It was very easy to set up and filled my needs perfectly.

夜灵血窟げ 2024-08-16 09:25:10

就这一点而言,您需要一个过滤器。

如果您想保留现有应用程序的架构,则需要定义和创建一组规则,将不友好的 URL 转换为友好的 URL,并让过滤器进行转换并将请求转发到不友好的 URL 。

如果无法修改现有应用程序,但您想基于此想法创建一个新应用程序,则可以考虑使用单个页面控制器来转换 HttpServletRequest#getPathInfo()/getRequestURI() 来执行适当的操作类(命令模式),最后将请求转发到适当的 JSP 页面。不确定它如何适合 Struts,因为我以前没有使用过 Struts。

To the point, you need a Filter for this.

If you want to keep your existing application's architecture, you'll need to define and create a set of rules to convert unfriendly urls to friendly urls and let the filter convert it and forward the request to the unfriendly url.

If there is no means of modifying an existing application but you want to create a new application based on this idea, you could consider to having a single page controller which translates the HttpServletRequest#getPathInfo()/getRequestURI() to execute the appropriate action class (command pattern) and finally forward the request to the appropriate JSP page. Not sure how that would fit into Struts as I haven't worked with Struts previously.

北城孤痞 2024-08-16 09:25:10

对于它的价值,您还可以查看 REST 插件 http:// /struts.apache.org/2.x/docs/rest-plugin.html,这将使您的 URL 更加友好

For what it's worth, you can also look at the REST plugin http://struts.apache.org/2.x/docs/rest-plugin.html, which amongst other things will make your URLs more friendly

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文