修改上传文件时记录请求内容报错的bug
This commit is contained in:
@@ -4,17 +4,13 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -25,14 +21,12 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigSource;
|
||||
import com.nis.domain.restful.FileDesc;
|
||||
import com.nis.domain.restful.MaatConfig;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.CompileVal;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.FileUtils;
|
||||
import com.nis.util.OracleErrorCodeUtil;
|
||||
import com.nis.util.ServiceAndRDBIndexReal;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.controller.BaseRestController;
|
||||
@@ -46,6 +40,8 @@ import com.wordnik.swagger.annotations.Api;
|
||||
import com.wordnik.swagger.annotations.ApiOperation;
|
||||
import com.wordnik.swagger.annotations.ApiParam;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @ClassName: ConfigSourcesController
|
||||
* @Description: 配置存储服务
|
||||
|
||||
@@ -182,39 +182,21 @@ public class SaveRequestLogThread implements Runnable {
|
||||
thread.setRequestURI(request.getRequestURI());
|
||||
if (request.getMethod().toLowerCase().equals("get")) {
|
||||
thread.setQueryString(request.getQueryString());
|
||||
thread.setContent(request.getQueryString());
|
||||
} else {
|
||||
String contentType = request.getContentType();
|
||||
if(contentType.equals("application/json")) {
|
||||
thread.setQueryString(getBodyString(request));
|
||||
if(!contentType.contains("multipart/form-data")) {
|
||||
String bodyString = getBodyString(request);
|
||||
thread.setQueryString(bodyString);
|
||||
thread.setContent(bodyString);
|
||||
}else {
|
||||
//String bodyString = getBodyString(request);
|
||||
thread.setQueryString("contentTyp="+contentType+",一般是上传文件,此种请求不记录请求内容");
|
||||
thread.setContent("contentTyp="+contentType+",一般是上传文件,此种请求不记录请求内容");
|
||||
}
|
||||
}
|
||||
thread.setContextPath(request.getContextPath());
|
||||
thread.setRequestTime(new Date());
|
||||
BufferedReader reader = null;
|
||||
String line = null;
|
||||
StringBuilder bulider = new StringBuilder();
|
||||
try {
|
||||
reader = request.getReader();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
bulider.append(new String(line.getBytes(), "utf-8"));
|
||||
bulider.append("\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bulider.toString().length() > 0) {
|
||||
thread.setContent(bulider.toString());
|
||||
}
|
||||
return thread;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user