Spring Servlet 从 *.html 映射到 SO 类型映射
我有一个 Spring 应用程序,其中一个 servlet 的 url 映射为 *.html。一切都与我带注释的控制器配合得很好。
我的问题是如何设置 servlet 和带注释的映射来模仿 StackOverflow 等 url?
我想访问一个无扩展名的网址,如果可能的话,在最后的 / 之后添加描述。
示例:
我目前有:
/appName/parm1/parm2/pageName.html
我想要
/appName/parm1/parm2/pageName/description
这可能吗?我需要对带注释的控制器做什么?
谢谢
I have a spring app with one servlet that has url-mapping of *.html. Everything is working great with my annotated controllers.
My question is how can I setup my servlet and annotated mappings to mimic the urls like StackOverflow?
I would like to go to a no extension url and if possible add a description after the final /.
Example:
I currently have:
/appName/parm1/parm2/pageName.html
I would like to have
/appName/parm1/parm2/pageName/description
Is this possible and what do I need to do to my annotated controllers?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够将调度程序 servlet 映射到 /* 或类似的内容,然后使用 @PathVariables 从 URI 获取所需的信息。看看 http://static.springsource .org/spring/docs/current/spring-framework-reference/html/mvc.html 并搜索@PathVariable。下面是该页面的一个示例
,它从请求 uri 中读取ownerId 和petId。
You should be able to map the dispatcher servlet to /* or something like that, and then use @PathVariables to get the needed information from the URI. Have a look at http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html and search for @PathVariable. Here's an example from that page
which reads the ownerId and the petId from the request uri.