【发布时间】:2016-04-15 14:48:23
【问题描述】:
我们有一个 Spring MVC 控制器方法,它为 url 模式 /hello/{userName} 提供服务。
@RequestMapping("/hello/{userName}")
public ModelAndView helloWorld(@PathVariable("userName") String productId) {
String message = "HELLO"+userName;
return new ModelAndView("hellopage", "message", message);
}
这里当我们请求 /hello/Tom 时,hellopage.html 将在浏览器中使用 URL http://localhost:8080/myApp/hello/Tom 进行服务
我们需要 URL 为 http://localhost:8080/myApp/Tom。有什么方法可以设置从控制器返回时在浏览器中显示的 URL。
【问题讨论】: