Update README.md

This commit is contained in:
synchronized 2018-05-15 08:32:50 +08:00 committed by GitHub
parent d2eebec71e
commit da6e74a9fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -54,12 +54,12 @@ dependencies {
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>CaptchaServlet</servlet-name> <servlet-name>CaptchaServlet</servlet-name>
<url-pattern>/image/captcha</url-pattern>    <url-pattern>/images/captcha</url-pattern>
</servlet-mapping> </servlet-mapping>
``` ```
2.前端代码 2.前端代码
```html ```html
<img src="/image/captcha" /> <img src="/images/captcha" />
``` ```
### 在*SpringMVC*中使用 ### 在*SpringMVC*中使用
@ -77,7 +77,7 @@ public void captcha(HttpServletRequest request, HttpServletResponse response) {
``` ```
前端代码: 前端代码:
```html ```html
<img src="/image/captcha" /> <img src="/images/captcha" />
``` ```
### 前后端分离中使用 ### 前后端分离中使用
@ -97,7 +97,7 @@ public void captcha(String key, HttpServletRequest request, HttpServletResponse
前后端分离也同样可以使用框架自带的servlet使用方式如下 前后端分离也同样可以使用框架自带的servlet使用方式如下
```html ```html
<img src="/image/captcha?key=xxx" /> <img src="/images/captcha?key=xxx" />
<!-- 此处的key应该有js随机生成并且js在验证的时候也需要传递这个key --> <!-- 此处的key应该有js随机生成并且js在验证的时候也需要传递这个key -->
``` ```
@ -131,4 +131,4 @@ CaptchaUtil captcha = new CaptchaUtil(130, 38, 5);
CaptchaUtil captcha = new CaptchaUtil(); CaptchaUtil captcha = new CaptchaUtil();
captcha.setCodeName("captcha"); captcha.setCodeName("captcha");
``` ```
默认存在session中是以captcha为key存储的存储在servletContext中是以captcha-xxx为key存储的xxx是生成的时候前端传递的key。 默认存在session中是以captcha为key存储的存储在servletContext中是以captcha-xxx为key存储的xxx是生成的时候前端传递的key。