重构工具类
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/30 18:56
|
||||
*/
|
||||
public class MD5Util {
|
||||
public static String getMD5(String str) {
|
||||
String md5 = DigestUtils.md5DigestAsHex(str.getBytes());
|
||||
return md5;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/10/18 15:44
|
||||
* @Description:
|
||||
*/
|
||||
public class RequestUtil {
|
||||
public static String getCompleteUrlAndMethod(HttpServletRequest request) {
|
||||
// like this : /articles?page=1&count=5:GET
|
||||
return request.getRequestURI() +
|
||||
(request.getQueryString() == null ? "" : "?" + request.getQueryString()) +
|
||||
":" + request.getMethod();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 17:21
|
||||
*/
|
||||
public class StringFromHtmlUtil {
|
||||
public static String getString(String html) {
|
||||
//从html中提取纯文本
|
||||
//剔出<html>的标签
|
||||
String txtcontent = html.replaceAll("</?[^>]+>", "");
|
||||
//去除字符串中的空格,回车,换行符,制表符
|
||||
txtcontent = txtcontent.replaceAll("<a>\\s*|\t|\r|\n</a>", "");
|
||||
return txtcontent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 17:21
|
||||
*/
|
||||
public class StringUtil {
|
||||
/**
|
||||
* 从html中提取纯文本
|
||||
*
|
||||
* @param html html string
|
||||
* @return 纯文本
|
||||
*/
|
||||
public static String getString(String html) {
|
||||
//剔出<html>的标签
|
||||
String txtcontent = html.replaceAll("</?[^>]+>", "");
|
||||
//去除字符串中的空格,回车,换行符,制表符
|
||||
txtcontent = txtcontent.replaceAll("<a>\\s*|\t|\r|\n</a>", "");
|
||||
return txtcontent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成MD5
|
||||
*
|
||||
* @param str 源数据
|
||||
* @return md5 内容
|
||||
*/
|
||||
public static String getMD5(String str) {
|
||||
return DigestUtils.md5DigestAsHex(str.getBytes());
|
||||
}
|
||||
|
||||
public static String getCompleteUrlAndMethod(HttpServletRequest request) {
|
||||
// like this : GET:/articles?page=1&count=5
|
||||
return request.getMethod() + ":" + request.getRequestURI() +
|
||||
(request.getQueryString() == null ? "" : "?" + request.getQueryString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +79,8 @@ public class VeriCodeUtil {
|
||||
*/
|
||||
public static Color getRandomColor() {
|
||||
Random ran = new Random();
|
||||
Color color = new Color(ran.nextInt(256),
|
||||
return new Color(ran.nextInt(256),
|
||||
ran.nextInt(256), ran.nextInt(256));
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user