正则 定义为常量

This commit is contained in:
WangHao 2020-08-27 21:54:51 +08:00
parent 96672852ae
commit 395c945b77
2 changed files with 4 additions and 1 deletions

View File

@ -15,6 +15,7 @@ public class Const {
public static String LOGIN_SESSION_KEY = "Favorites_user"; public static String LOGIN_SESSION_KEY = "Favorites_user";
public static String PASSWORD_KEY = "@#$%^&*()OPG#$%^&*(HG"; public static String PASSWORD_KEY = "@#$%^&*()OPG#$%^&*(HG";
public static String URL_CODE = "(?<=charset=)(.+)(?=\")";//取网址的编码
public static String DES3_KEY = "9964DYByKL967c3308imytCB"; public static String DES3_KEY = "9964DYByKL967c3308imytCB";
@ -29,6 +30,8 @@ public class Const {
public static int COOKIE_TIMEOUT= 30*24*60*60; public static int COOKIE_TIMEOUT= 30*24*60*60;
// @Autowired(required = true) // @Autowired(required = true)
// public void setBasePath(@Value("${favorites.base.path}")String basePath) { // public void setBasePath(@Value("${favorites.base.path}")String basePath) {
// Const.BASE_PATH = basePath; // Const.BASE_PATH = basePath;

View File

@ -283,7 +283,7 @@ public class ImportHtml {
// } // }
// //
public static String matchCharset(String content) { public static String matchCharset(String content) {
Pattern p = Pattern.compile("(?<=charset=)(.+)(?=\")"); Pattern p = Pattern.compile(Const.URL_CODE);
Matcher m = p.matcher(content); Matcher m = p.matcher(content);
if (m.find()){ if (m.find()){
return m.group(); return m.group();