|
@@ -13,6 +13,8 @@ import javax.servlet.ServletRequest;
|
|
|
import javax.servlet.ServletResponse;
|
|
import javax.servlet.ServletResponse;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+
|
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.context.support.WebApplicationContextUtils;
|
|
import org.springframework.web.context.support.WebApplicationContextUtils;
|
|
|
import org.springframework.web.context.support.XmlWebApplicationContext;
|
|
import org.springframework.web.context.support.XmlWebApplicationContext;
|
|
|
|
|
|
|
@@ -37,8 +39,9 @@ public class KeyWordFilter implements Filter {
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
response.setContentType("application/json; charset=utf-8");
|
|
response.setContentType("application/json; charset=utf-8");
|
|
|
String contentType = req.getContentType();
|
|
String contentType = req.getContentType();
|
|
|
- // 不是get请求,并且不是附件上传请求
|
|
|
|
|
- if(!req.getMethod().equals("GET") && !contentType.contains("multipart")){
|
|
|
|
|
|
|
+ String method = req.getMethod();
|
|
|
|
|
+ // POST请求 或 PUT请求,并且不是附件上传请求
|
|
|
|
|
+ if(("POST".equals(method) || "PUT".equals(method)) && (StringUtils.isEmpty(contentType) || !contentType.contains("multipart"))){
|
|
|
//注入Service
|
|
//注入Service
|
|
|
ServletContext sc = req.getSession().getServletContext();
|
|
ServletContext sc = req.getSession().getServletContext();
|
|
|
XmlWebApplicationContext cxt = (XmlWebApplicationContext) WebApplicationContextUtils.getWebApplicationContext(sc);
|
|
XmlWebApplicationContext cxt = (XmlWebApplicationContext) WebApplicationContextUtils.getWebApplicationContext(sc);
|