Open moonpure opened 4 years ago
package org.jeecgframework.poi.excel.view;
import javax.servlet.http.HttpServletRequest; import org.springframework.web.servlet.view.AbstractView;
public abstract class MiniAbstractExcelView extends AbstractView { private static final String CONTENT_TYPE = "application/vnd.ms-excel"; protected static final String HSSF = ".xls"; protected static final String XSSF = ".xlsx";
public MiniAbstractExcelView() { this.setContentType("application/vnd.ms-excel"); } protected boolean isIE(HttpServletRequest request) { return request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0 || request.getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0; }
}
以上代码。当通过 mockmvc等进行测试时,如没有上传USER-AGENT会报错。为我这种小白增加困难,如能加入null 判断。则可解决
好的
package org.jeecgframework.poi.excel.view;
import javax.servlet.http.HttpServletRequest; import org.springframework.web.servlet.view.AbstractView;
public abstract class MiniAbstractExcelView extends AbstractView { private static final String CONTENT_TYPE = "application/vnd.ms-excel"; protected static final String HSSF = ".xls"; protected static final String XSSF = ".xlsx";
}
以上代码。当通过 mockmvc等进行测试时,如没有上传USER-AGENT会报错。为我这种小白增加困难,如能加入null 判断。则可解决