mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-08 13:27:46 +00:00
解决header获取username中文情况下乱码
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
package com.ruoyi.common.core.utils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.ruoyi.common.core.exception.BaseException;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import com.ruoyi.common.core.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
/**
|
||||
* 权限获取工具类
|
||||
*
|
||||
@@ -17,7 +22,13 @@ public class SecurityUtils
|
||||
*/
|
||||
public static String getUsername()
|
||||
{
|
||||
return ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USERNAME);
|
||||
String username = "";
|
||||
try {
|
||||
username = URLDecoder.decode(ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USERNAME), "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new BaseException("获取username失败");
|
||||
}
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user