1.在项目的WEB-INF下的lib目录添加maskbarcode.jar
2.配置web.xml文件,代码如下:
1. <?xml version="1.0" encoding="UTF-8"?>
2. <web-app version="2.5"
3. xmlns="http://java.sun.com/xml/ns/javaee"
4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
6. http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
7.
8. <!-- 配置条形码 -->
9. <servlet>
10. <servlet-name>maskbarcode</servlet-name>
11. <servlet-class>
12. com.mask.util.barcode.BarCodeServlet
13. </servlet-class>
14. <load-on-startup>1</load-on-startup>
15. </servlet>
16.
17. <servlet-mapping>
18. <servlet-name>maskbarcode</servlet-name>
19. <url-pattern>*.bar</url-pattern>
20. </servlet-mapping>
21.
22.
23. <welcome-file-list>
24. <welcome-file>index.jsp</welcome-file>
25. </welcome-file-list>
26. </web-app>
3.编写测试界面,就index.jsp吧
1. <%@ page language="java" pageEncoding="GBK"%>
2. <html>
3. <head>
4. <title>条形码</title>
5. </head>
6. <body>
7. <img src="maskbarcode.bar?code=0123456789" mce_src="maskbarcode.bar?code=0123456789"/>
8. </body>
9. </html>
4.运行效果
备注: