2、控制层如:BaseController public class BaseController extends Controller { public boolean isIEBrowser() { return RequestUtil.isIEBrowser(getRequest()); }
public void render(String message, Integer errorCode, Object data) { Result ret = new Result(); ret.setMessage(message); ret.setErrorCode(errorCode); ret.setData(data);
1、requestUtils代码:
public static boolean isIEBrowser(HttpServletRequest request) {
String ua = request.getHeader("User-Agent");
if (ua == null) {
return false;
}
ua = ua.toLowerCase();
if (ua.indexOf("msie") > 0) {
return true;
}
if (ua.indexOf("gecko") > 0 && ua.indexOf("rv:11") > 0) {
return true;
}
return false;
}
2、控制层如:BaseController
public class BaseController extends Controller {
public boolean isIEBrowser() {
return RequestUtil.isIEBrowser(getRequest());
}
public void render(String message, Integer errorCode, Object data) {
Result ret = new Result();
ret.setMessage(message);
ret.setErrorCode(errorCode);
ret.setData(data);
if (isIEBrowser()) {
render(new JsonRender(ret).forIE());
} else {
renderJson(ret);
}
}