页面上的提交包含文件,所以只能用这种formdata方式
$.ajax({
url:form.action,
type:'post',
data:new FormData(form),
// dataType: "json",
processData: false,
// contentType: 'multipart/form-data',//导致 no multipart boundary was found
contentType:false,
// success:
}).done(r=>{
if(r.code==200)
alert("oprate done..")||form.reset();
else
alert("error:"+r.msg);
});
提交的数据总是乱码
但是其他非formdata的请求不乱码
最后发现把这一段代码删除,就不再乱码
暂时没找到更好的办法
@WebListener
@Component
public class ParaListener implements ServletRequestListener {
org.slf4j.Logger logger= org.slf4j.LoggerFactory.getLogger(getClass());
@Override
public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
}
@Override
public void requestInitialized(ServletRequestEvent servletRequestEvent) {
ServletRequest request = servletRequestEvent.getServletRequest();
// HttpServletRequest request = (HttpServletRequest) req;//
// String path=request.getServletPath();
String path=((HttpServletRequest) request ).getRequestURI();//.getServletContext().getContextPath();//.getRequestURI();
Map para = request.getParameterMap();
String strpara = JsonTool.stringify(para);//.toString();//JSON.toJSONString(para);
// new Date().toLocaleString()+
logger.warn("--------------------收到请求,请求的路径是\t"+path);
logger.warn("参数是:\t"+strpara);
}
}