为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

老二非死不可

老二非死不可

方三文 / 机械工业出版社 / 2013-12 / 39.00

关于投资 价值投资者为啥都买茅台? 怎样识别好公司与坏公司? 做空者真的罪大恶极吗? 国际板对A股会有什么影响? 波段操作,止损割肉到底靠不靠谱? IPO真的是A股萎靡不振的罪魁祸首吗? 关于商业 搜狐的再造战略有戏吗? 新浪如何焕发第二春? 百度的敌人为什么是它自己? 我为什么比巴菲特早两年投资比亚迪? 民族品牌这张牌还靠谱......一起来看看 《老二非死不可》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

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

HSV CMYK互换工具