| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 获取Boolean参数
|
| | | */
|
| | | public static Boolean getParameterToBool(String name)
|
| | | {
|
| | | return Convert.toBool(getRequest().getParameter(name));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取Boolean参数
|
| | | */
|
| | | public static Boolean getParameterToBool(String name, Boolean defaultValue)
|
| | | {
|
| | | return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取request
|
| | | */
|
| | | public static HttpServletRequest getRequest()
|
| | |
| | | *
|
| | | * @param response 渲染对象
|
| | | * @param string 待渲染的字符串
|
| | | * @return null
|
| | | */
|
| | | public static String renderString(HttpServletResponse response, String string)
|
| | | public static void renderString(HttpServletResponse response, String string)
|
| | | {
|
| | | try
|
| | | {
|
| | |
| | | {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | public static boolean isAjaxRequest(HttpServletRequest request)
|
| | | {
|
| | | String accept = request.getHeader("accept");
|
| | | if (accept != null && accept.indexOf("application/json") != -1)
|
| | | if (accept != null && accept.contains("application/json"))
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | String xRequestedWith = request.getHeader("X-Requested-With");
|
| | | if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
|
| | | if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest"))
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | String ajax = request.getParameter("__ajax");
|
| | | if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | return StringUtils.inStringIgnoreCase(ajax, "json", "xml");
|
| | | }
|
| | | }
|