jsp ajax上傳標籤原始版本

來源:互聯網
上載者:User

好久沒有更新部落格了,寫了個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>

這樣就可以調用了

這才是最基礎的上傳,我近幾天會把功能做的更完善點,然後會把代碼發出來,一起去研究,一起探討。

本文配套源碼

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.