Java和SEO URL

ham*_*amo 5 java seo spring-mvc

我正在使用spring MVC构建一个webapp,我很好奇是否有任何干净的方式来制作SEO网址.

例如,代替http://mysite.com/articles/articleId等,有:

http://mysite.com/articles/my-article-subject

Dic*_*ood 6

如果您正在使用新的Spring-MVC注释,则可以使用@RequestMapping和@PathVariable注释:

@RequestMapping("/articles/{subject}")
public ModelAndView findArticleBySubject(@PathVariable("subject") String subject)
{
   // strip out the '-' character from the subject
   // then the usual logic returning a ModelAndView or similar
}
Run Code Online (Sandbox Code Playgroud)

我认为仍然需要删除 - 字符.


小智 5

这可能是您感兴趣的:

http://tuckey.org/urlrewrite/

如果您熟悉Apache服务器上的mod_rewrite,这是一个类似的概念.