为Servlet添加支持REST式URL ServletREST

码农软件 · 软件分类 · REST/RESTful项目 · 2019-03-11 13:12:11

软件介绍

为Servlet添加支持REST式URL: 不改变习惯,仅仅在servlet内部完成doGet, doPost,doDelete,doPut等方法即可映射到较为复杂的REST URL

eg:

/book/head first java/
对应的URL表达式为:
/book/*/

/book/head first java/chapter/1
对应的URL表达式为:
/book/*/
chapter/*

您所要做的: 仅仅需要在web.xml中配置一个filter 仅仅需要在集成HttpServlet添加一个注解(eg:@RestSupport("/book/*/chapter/*"))

下面附加一个使用示范:

@RestSupport("/book/*/chapter/*")
public class ChapterServlet extends HttpServlet {
       
private static final long serialVersionUID = -1534235656L;

       
protected void doGet(HttpServletRequest request,
                       
HttpServletResponse response) throws ServletException, IOException {
               
// code here ...
       
}

       
protected void doPost(HttpServletRequest request,
                       
HttpServletResponse response) throws ServletException, IOException {
               
// code here ...
       
}

       
protected void doPut(HttpServletRequest request,
                       
HttpServletResponse response) throws ServletException, IOException {
               
// code here ...
       
}

       
protected void doDelete(HttpServletRequest request,
                       
HttpServletResponse response) throws ServletException, IOException {
               
// code here ...
       
}
}

本文地址:https://codercto.com/soft/d/1110.html

Creative Selection

Creative Selection

Ken Kocienda / St. Martin's Press / 2018-9-4 / USD 28.99

Hundreds of millions of people use Apple products every day; several thousand work on Apple's campus in Cupertino, California; but only a handful sit at the drawing board. Creative Selection recounts ......一起来看看 《Creative Selection》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具