zTree & ckeditor &ValidateCode.jar 使用个人心得总结

zTree:依靠 jQuery 实现的多功能 “树插件”。

使用时只需要将下载的压缩包接用,复制里边的css 和 js 到指定目录即可。

如图所示:

在zTree的官网可以找到各种类型树的示例:

地址如下:http://www.treejs.cn/v3/demo.php

当下载压缩包之后再相应的路径都可以找到相应的html文件,直接拿来用就欧克。

 

 

再使用给出的html示例时要更改引入的路径才能正确使用

 验证路径的方式是 按住CTRL 键时鼠标移到 href 或者 src 的路径 会出现下划线,点击会进入相应的源码当中。

ckeditor: 再网上可以找到相应的压缩包,引入 ckeditor 文件,导入相应的 js,路径可能不对,按如上方法修改。

通过     CKEDITOR.replace('area')  实现 对 textarea 的替换。
 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <meta charset="UTF-8">
 5 <title>Insert title here</title>
 6 <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
 7 </head>
 8 <body>
 9    <textarea  name="area"></textarea>
10    <script type="text/javascript">CKEDITOR.replace('area');</script>
11 </body>
12 </html>

效果图如下:

ValidateCode.jar 包是一个自动生成验证码的jar包。

使用时在Servlet 类中调用相关方法即可。

 1 import java.io.IOException;
 2 import javax.servlet.ServletException;
 3 import javax.servlet.annotation.WebServlet;
 4 import javax.servlet.http.HttpServlet;
 5 import javax.servlet.http.HttpServletRequest;
 6 import javax.servlet.http.HttpServletResponse;
 7 
 8 import cn.dsna.util.images.ValidateCode;
 9 
10 /**
11  * Servlet implementation class Servlet2
12  */
13 @WebServlet("/Servlet2")
14 public class Servlet2 extends HttpServlet {
15     private static final long serialVersionUID = 1L;
16        
17     /**
18      * @see HttpServlet#HttpServlet()
19      */
20     
21     public Servlet2() {
22         super();
23         // TODO Auto-generated constructor stub
24     }
25 
26     /**
27      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
28      */
29     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
30         // TODO Auto-generated method stub
31            //1.设置验证码图片的宽高
32         int width=120;
33         int height=50;
34         //2.生成验证码     参数1和2:宽和高       参数3:验证码的位数(一般是4位,比如7RV4,G86T等等)      参数4:干扰线的条数
35         ValidateCode code=new ValidateCode(width, height, 6, 4);
36         //3.输出验证码图片
37         code.write(response.getOutputStream());
38 
39         //4.将随机码存起备用 
40         String codeString=code.getCode();
41         System.out.println("====codeString======"+codeString);
42     }
43 
44     /**
45      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
46      */
47     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
48         // TODO Auto-generated method stub
49         doGet(request, response);
50     }
51     
52 
53 
54 }

jsp:

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html>
 4 <html>
 5 <head>
 6 <meta charset="UTF-8">
 7 <title>生成验证码</title>
 8 </head>
 9 <body>
10 <div align="center">
11 <!--   调用Servlet2 类中的方法 -->
12  <img src="Servlet2">
13  </div>
14 </body>
15 </html>

效果图如下:

猜你喜欢

转载自www.cnblogs.com/cxy0210/p/11979622.html
今日推荐