This commit is contained in:
zhuangqian 2016-09-06 08:45:37 +08:00
parent 82bf1a1117
commit e021279090
4 changed files with 17 additions and 11 deletions

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="SpringBlade"> <wb-module deploy-name="SpringBlade">
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>

View File

@ -43,6 +43,8 @@ import com.smallchill.core.toolbox.kit.StrKit;
*/ */
public class Captcha { public class Captcha {
private HttpServletResponse response;
private static String captchaName = "_tframework_captcha"; private static String captchaName = "_tframework_captcha";
// 默认的验证码大小 // 默认的验证码大小
@ -59,6 +61,10 @@ public class Captcha {
new Font(Font.MONOSPACED, Font.BOLD, 40) new Font(Font.MONOSPACED, Font.BOLD, 40)
}; };
public Captcha(HttpServletResponse response){
this.response = response;
}
/** /**
* 设置 captchaName * 设置 captchaName
*/ */
@ -72,7 +78,7 @@ public class Captcha {
/** /**
* 生成验证码 * 生成验证码
*/ */
public void render(HttpServletResponse response) { public void render() {
BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
String vCode = drawGraphic(image); String vCode = drawGraphic(image);
vCode = vCode.toUpperCase(); // 转成大写重要 vCode = vCode.toUpperCase(); // 转成大写重要

View File

@ -20,7 +20,13 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
public class CookieKit { public class CookieKit {
/**
* Get cookie value by cookie name.
*/
public static String getCookie(String name, HttpServletRequest request) {
return getCookie(name, null, request);
}
/** /**
* Get cookie value by cookie name. * Get cookie value by cookie name.
@ -29,13 +35,6 @@ public class CookieKit {
Cookie cookie = getCookieObject(name, request); Cookie cookie = getCookieObject(name, request);
return cookie != null ? cookie.getValue() : defaultValue; return cookie != null ? cookie.getValue() : defaultValue;
} }
/**
* Get cookie value by cookie name.
*/
public static String getCookie(String name, HttpServletRequest request) {
return getCookie(name, null, request);
}
/** /**
* Get cookie object by cookie name. * Get cookie object by cookie name.

View File

@ -122,7 +122,7 @@ public class LoginController extends BaseController implements Const{
@RequestMapping("/captcha") @RequestMapping("/captcha")
public void captcha(HttpServletResponse response) { public void captcha(HttpServletResponse response) {
new Captcha().render(response); new Captcha(response).render();
} }
public void doLog(Session session, String type){ public void doLog(Session session, String type){