我在spring mvc应用程序中使用pathvariable时遇到问题。
我有两个像这样的控制器
@RequestMapping(@RequestMapping(value = { "BuyPackage/{company_code}" }, method = RequestMethod.GET)
public String controller1(@PathVariable("company_code")int company_code){
............
}
@RequestMapping(@RequestMapping(value = { "Preview" }, method = RequestMethod.POST)
public String controller2(){
............
}
当第一个控制器调用url为localhost:8080/myapp/BuyPackage/1
然后当第二个控制器调用url转到localhost:8080/myapp/BuyPackage/Preview
时发生错误。
网址应如下所示:localhost:8080/myapp/Preview
任何人都可以帮我解决这个问题吗?
答案 0 :(得分:0)
您可以使用jstl。尝试将其与您的链接<c:url value='/Preview' />
示例:<a href="<c:url value='/Preview' />">Link to Preview</a>