Java 未找到请求资源状态404
我收到此错误,请帮助我解决此错误。我正在使用spring json rest。此错误主要发生在发出请求时。那么您的错误是什么?您如何提出请求?可能的重复Java 未找到请求资源状态404,java,xml,spring,Java,Xml,Spring,我收到此错误,请帮助我解决此错误。我正在使用spring json rest。此错误主要发生在发出请求时。那么您的错误是什么?您如何提出请求?可能的重复 package com.test.controller; import java.util.List; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import o
package com.test.controller;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.test.dao.UserDAOImpl;
import com.test.model.User;
@Controller
@RequestMapping("/service/user/")
public class SpringRestController {
UserDAOImpl userDAOImpl=new UserDAOImpl();
@RequestMapping(value = "/{id}", method = RequestMethod.GET,headers="Accept=application/json")
public User getUser(@PathVariable int id) {
User user=userDAOImpl.getUserById(id);
return user;
}
@RequestMapping(method = RequestMethod.GET,headers="Accept=application/json")
public List<User> getAllUsers() {
List<User> users=userDAOImpl.getAllUsers();
return users;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>sample</display-name>
<servlet><servlet-name>rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
localhost:8080/sample/service/user/