为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

数论概论

数论概论

希尔弗曼 / 孙智伟 / 机械工业出版社 / 2008-5 / 42.00元

《数论概论(原书第3版)》讲述了有关数论大量有趣的知识,以及数论的一般方法和应用,循序渐进地启发读者用数学方法思考问题,此外还介绍了目前数论研究的某些前沿课题。《数论概论(原书第3版)》采用轻松的写作风格,引领读者进入美妙的数论世界,不断激发读者的好奇心,并通过一些精心设计的练习来培养读者的探索精神与创新能力。一起来看看 《数论概论》 这本书的介绍吧!

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具