[英]Why i get 404 error trying to acess a rest?
当我尝试访问以下网址时,我收到404错误:
GET: /test/{id}
PS .: id是根据用户过滤器而变化的字符串
我已经在web.xml中映射了“ / test”,但是我不知道如何声明“我不知道”的某些值,在这种情况下为“ id”。
让我举一个例子:
@RequestMapping(value="/test/{id}", method = RequestMethod.GET)
public ModelAndView testingId(@PathVariable String id ){
System.out.println("id");
return new ModelAndView("returns", "returns", id);
}
有帮助吗?
您使用什么方法来配置Web应用程序DispatcherServlet(web.xml或WebApplicationInitializer)
您的请求需要包括servlet上下文,servlet映射和资源映射。 假设您的应用程序名为sample.war,并且您的DispatcherServlet映射到/ app / *,则您的请求应为
GET:/ sample / app / test / 4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.