代码优化

This commit is contained in:
稚屿
2022-02-09 09:10:50 +08:00
parent a29201a248
commit c99eb98001
16 changed files with 37 additions and 57 deletions

View File

@ -99,9 +99,8 @@ public class ServletUtils
*
* @param response 渲染对象
* @param string 待渲染的字符串
* @return null
*/
public static String renderString(HttpServletResponse response, String string)
public static void renderString(HttpServletResponse response, String string)
{
try
{
@ -114,7 +113,6 @@ public class ServletUtils
{
e.printStackTrace();
}
return null;
}
/**
@ -125,13 +123,13 @@ public class ServletUtils
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;
}
@ -143,10 +141,6 @@ public class ServletUtils
}
String ajax = request.getParameter("__ajax");
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
{
return true;
}
return false;
return StringUtils.inStringIgnoreCase(ajax, "json", "xml");
}
}