57 lines
1.6 KiB
Java
57 lines
1.6 KiB
Java
package cn.servlet;
|
|
|
|
import java.io.IOException;
|
|
|
|
import javax.servlet.ServletException;
|
|
import javax.servlet.http.HttpServlet;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import cn.access.authority.AnnotationRestfullDispatcherImpl;
|
|
import cn.access.dispatcher.RestfullDispatcher;
|
|
|
|
|
|
/**
|
|
* Restfull处理Servlet
|
|
*
|
|
* @author yangsong
|
|
* @date 2015年3月29日
|
|
*/
|
|
public class RestfullServiceServlet extends HttpServlet{
|
|
|
|
private static final long serialVersionUID = 7870933012826130781L;
|
|
protected Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
protected RestfullDispatcher dispatcher = null;
|
|
|
|
|
|
public void init() throws ServletException {
|
|
super.init();
|
|
dispatcher = new AnnotationRestfullDispatcherImpl();
|
|
dispatcher.init(getServletContext());
|
|
}
|
|
|
|
//===============================
|
|
//POST,DELETE,PUT,GET四个基础方法
|
|
//===============================
|
|
protected void doPost(HttpServletRequest req, HttpServletResponse rep)
|
|
throws ServletException, IOException {
|
|
dispatcher.doPost(req, rep);
|
|
}
|
|
protected void doDelete(HttpServletRequest req, HttpServletResponse rep)
|
|
throws ServletException, IOException {
|
|
dispatcher.doDelete(req, rep);
|
|
}
|
|
protected void doPut(HttpServletRequest req, HttpServletResponse rep)
|
|
throws ServletException, IOException {
|
|
dispatcher.doPut(req, rep);
|
|
}
|
|
protected void doGet(HttpServletRequest req, HttpServletResponse rep)
|
|
throws ServletException, IOException {
|
|
dispatcher.doGet(req, rep);
|
|
}
|
|
}
|
|
|