jsp ajax上传标签原始版本
2009-09-22 00:00:00 来源:WEB开发网好久没有更新博客了,写了个jsp 上传组件给大家看看
1.下载下来,新建个j2ee工程,把qingcai-upload.jar放到lib下,然后upload.tld放到WEB-INF下。
2.在web.xml
例如:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
id="WebApp_ID" version="2.4">
<display-name>aa</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/upload</taglib-uri>
<taglib-location>/WEB-INF/upload.tld</taglib-location>
</taglib>
<servlet>
<servlet-name>UploadServlet</servlet-name>
<servlet-class>com.qingcai.upload.servlet.UploadServlet</servlet-class>
<init-param>
<param-name>savePath</param-name>
<param-value>C:\\upload\\</param-value>
</init-param>
<init-param>
<param-name>extension</param-name>
<param-value>gif,rar</param-value>
</init-param>
<init-param>
<param-name>maxFileSize</param-name>
<param-value>20</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/fileupload</url-pattern>
</servlet-mapping>
</web-app>
3.新建个jsp
如
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<%@ taglib uri="/upload" prefix="qingcaiUpload"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Insert title here</title>
</head>
<body>
<qingcaiUpload:upload/>
</body>
</html>
这样就可以调用了
这才是最基础的上传,我近几天会把功能做的更完善点,然后会把代码发出来,一起去研究,一起探讨。
本文示例源代码或素材下载
更多精彩
赞助商链接