This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
一个JWT实际上就是一个字符串,它由三部分组成,头部、载荷与签名。 | |
头部用于描述关于该JWT的最基本的信息,例如其类型以及签名所用的算法等。这也可以被表示成一个JSON对象。 | |
例如:{"typ": "JWT","alg": "HS256"},对其进行base64编码后得到eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9。 | |
载荷也用json表示: | |
{ | |
"iss": "John Wu JWT", | |
"iat": 1441593502, | |
"exp": 1441594722, | |
"aud": "www.example.com", | |
"sub": "[email protected]", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.在web.xml中添加监听 | |
<listener> | |
<listener-class>com......listener.InitLibraryPath</listener-class> | |
</listener> | |
2.读取src/main/resources/sigar目录下的所有内容 | |
import javax.servlet.ServletContextEvent; | |
import javax.servlet.ServletContextListener; | |
import com.google.common.io.Resources; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.OutputStream; | |
import org.apache.commons.net.ftp.FTPClient; | |
import org.apache.commons.net.ftp.FTPFile; | |
import org.apache.log4j.Logger; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
明文显示邮箱: | |
https://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&[email protected] | |
使用QQ邮箱生成的代码: | |
<a target="_blank" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=lO7t_Mvg89Ty__z59f34uvf7_Q" style="text-decoration:none;"><img src="http://rescdn.qqmail.com/zh_CN/htmledition/images/function/qm_open/ico_mailme_02.png"/></a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.github.jhipster.config.JHipsterConstants; | |
import org.aspectj.lang.JoinPoint; | |
import org.aspectj.lang.ProceedingJoinPoint; | |
import org.aspectj.lang.annotation.AfterThrowing; | |
import org.aspectj.lang.annotation.Around; | |
import org.aspectj.lang.annotation.Aspect; | |
import org.aspectj.lang.annotation.Pointcut; | |
import org.slf4j.Logger; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ ! -n "${LIQUIBASE_HOME+x}" ]; then | |
# echo "LIQUIBASE_HOME is not set." | |
## resolve links - $0 may be a symlink | |
PRG="$0" | |
while [ -h "$PRG" ] ; do | |
ls=`ls -ld "$PRG"` | |
link=`expr "$ls" : '.*-> \(.*\)$'` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response.setCharacterEncoding(request.getCharacterEncoding()); | |
response.setContentType(MediaType.APPLICATION_OCTET_STREAM.toString()); | |
String realFileName = URLEncoder.encode(realFileName, StandardCharsets.UTF_8.toString()); | |
// 解决中文文件名乱码关键行 | |
response.setHeader("Content-Disposition", "attachment; filename=\"" + realFileName + "\"; filename*=utf-8''" + realFileName); | |
Path path = Paths.get(filePath+filename); | |
Files.copy(path, response.getOutputStream()); | |
response.flushBuffer(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1当普通调用时,一般跳转到自定义的错误页面。 | |
//2当ajax调用时,可返回约定的数据对象,方便页面统一处理。 | |
import java.util.HashMap; | |
import java.util.Map; | |
import javax.servlet.http.HttpServletRequest; | |
import org.springframework.web.bind.annotation.ControllerAdvice; | |
import org.springframework.web.bind.annotation.ExceptionHandler; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.sql.DataSource; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
import org.springframework.security.config.annotation.web.builders.WebSecurity; | |
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.beans.BeansException; | |
import org.springframework.context.ApplicationContext; | |
import org.springframework.context.ApplicationContextAware; | |
import org.springframework.stereotype.Component; | |
@Component | |
public class SpringContextUtil implements ApplicationContextAware { | |
private static ApplicationContext applicationContext; // Spring应用上下文环境 | |
/* |
OlderNewer