[英]Spring mvc: Dynamic 404 page
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>
This is my current configuration for 404 errors. 这是我当前的404错误配置。
What I want: When a person types www.host.com/word . 我想要的是:一个人键入www.host.com/word时。 I want the string "word" as input for my search url (which is www.host.com/search.do?keyword). 我希望将字符串“ word”作为我的搜索网址(即www.host.com/search.do?keyword)的输入。
Does anyone know how to do this? 有谁知道如何做到这一点?
Map /
to your DispatcherServlet
(see section 16.2 of the Spring reference documentation) and set up a URI template as shown in section 16.3.2.1 . 地图/
你DispatcherServlet
(见第16.2 Spring参考文档),并成立了一个URI模板,如图节16.3.2.1 。 For example, you could set up a request mapping like so: 例如,您可以像这样设置请求映射:
@RequestMapping(value="/{keyword}", method=RequestMethod.GET)
public ModelAndView doSearch(@PathVariable("keyword") String keyword)
{
// forward to your search page
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.