struts2
- action里写接口,采集,或app调用这里的接口
- service可以跟数据库交互,在action里调用service的方法,这样子代码更加简洁
- struts.xml里注册action的方法
下面是一个action的方法
public String businessCarports() throws IOException{
HttpServletRequest request = (HttpServletRequest) ActionContext.getContext()
.get(ServletActionContext.HTTP_REQUEST);
ServletInputStream is = request.getInputStream();
String body = IOUtils.toString(is);
com.gexin.fastjson.JSONObject jsStr = com.gexin.fastjson.JSONObject.parseObject(body);
// System.out.println("mytest"+jsStr);
ParkService parkService=new ParkServiceImpl();
// parkService.startParkMsg(jsStr);
return SUCCESS;
}