[英]Why i get 404 error trying to acess a rest?
im getting 404 error when i try to visit an url like: 当我尝试访问以下网址时,我收到404错误:
GET: /test/{id}
PS.: id is a string that changes according users filter PS .: id是根据用户过滤器而变化的字符串
I have "/test" already mapped in web.xml, but i dont know how to declare some value that "i dont know", in this case, "id". 我已经在web.xml中映射了“ / test”,但是我不知道如何声明“我不知道”的某些值,在这种情况下为“ id”。
Let me show an example: 让我举一个例子:
@RequestMapping(value="/test/{id}", method = RequestMethod.GET)
public ModelAndView testingId(@PathVariable String id ){
System.out.println("id");
return new ModelAndView("returns", "returns", id);
}
Any Help? 有帮助吗?
What method are you using to configure your web application DispatcherServlet (web.xml or WebApplicationInitializer) 您使用什么方法来配置Web应用程序DispatcherServlet(web.xml或WebApplicationInitializer)
Your request needs to include the servlet context , servlet mapping and resource mapping. 您的请求需要包括servlet上下文,servlet映射和资源映射。 Assuming that your application is called sample.war and your DispatcherServlet is mapped to /app/* then your request should be 假设您的应用程序名为sample.war,并且您的DispatcherServlet映射到/ app / *,则您的请求应为
GET : /sample/app/test/4 GET:/ sample / app / test / 4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.