spring 3 mvc请求映射动态参数问题
我有以下代码可以正常使用 http://localhost:8080/HelloWorldSpring3/forms/helloworld
但我想让网址有一些像这样的事情
http://localhost:8080/HelloWorldSpring3/forms/helloworld/locname_here/locid_here< /a>
我发现添加这个 @RequestMapping("/helloworld/**") 会起作用,但是当我尝试访问
http://localhost:8080/HelloWorldSpring3/forms/helloworld/locname_here/locid_here
找不到。
Web.xml 条目如下
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/forms/*</url-pattern>
</servlet-mapping>
映射 bean 条目
@RequestMapping("/helloworld/**")
public ModelAndView helloWord(){
String message = "Hello World, Spring 3.0!";
return new ModelAndView("helloworld", "message",message);
}
I have the following code which works fine with
http://localhost:8080/HelloWorldSpring3/forms/helloworld
but i want to have url have some thing like this
http://localhost:8080/HelloWorldSpring3/forms/helloworld/locname_here/locid_here
I found that adding this @RequestMapping("/helloworld/**") will work but when i try to access
http://localhost:8080/HelloWorldSpring3/forms/helloworld/locname_here/locid_here
it is not found.
Web.xml entry as follows
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/forms/*</url-pattern>
</servlet-mapping>
Mapping bean entry
@RequestMapping("/helloworld/**")
public ModelAndView helloWord(){
String message = "Hello World, Spring 3.0!";
return new ModelAndView("helloworld", "message",message);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上面的代码可以满足您的要求。
The above code works for your requirement.