JavaServlet注释
有没有办法使用纯Java servlet而不是spring mvc请求映射将URL映射到方法 比如:JavaServlet注释,java,servlets,Java,Servlets,有没有办法使用纯Java servlet而不是spring mvc请求映射将URL映射到方法 比如: @GET(/path/of/{id}) 也可以使用“普通的”servlet(heck、SpringMVC和JAX-RS也构建在ServletAPI之上),它只需要多一点样板文件 @WebServlet("/path/of/*") public class PathOfServlet extends HttpServlet { @Override prote
@GET(/path/of/{id})
也可以使用“普通的”servlet(heck、SpringMVC和JAX-RS也构建在ServletAPI之上),它只需要多一点样板文件
@WebServlet("/path/of/*")
public class PathOfServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String id = request.getPathInfo().substring(1);
// ...
}
}
就这些。由于新的Servlet3.0@WebServlet
注释,您不需要任何web.xml
条目
另见: