springMVC easyUI filebox 單個檔案上傳,springmvceasyui

來源:互聯網
上載者:User

springMVC easyUI filebox 單個檔案上傳,springmvceasyui

被這個檔案上傳坑到現在,還是自己技術問題,照著之前extjs項目那邊的上傳執行個體,愣是上傳不了

到後面就查了下springMVC的檔案上傳,按照那樣搞定了http://blog.csdn.net/jadyer/article/details/7575934

easyui 前端檔案

<form id="brandAddForm" method="post" enctype="multipart/form-data">  <table cellpadding="5">                <tr>                    <td>名稱:</td>                    <td><input class="easyui-textbox" type="text" name="name" data-options="required:true" style="width:200px"></input></td>                </tr>                <tr>                   <td>描述:</td>                    <td><input class="easyui-textbox" name="description" data-options="multiline:true" style="height:100px;width:200px"></input></td>                </tr>                <tr>                    <td>URL:</td>                    <td><input class="easyui-textbox" name="url" style="width:200px"></td>                </tr>                <tr>                    <td>LOGO:</td>                    <td><input class="easyui-filebox" name="sourceFile" style="width:200px"></td>                </tr>               <tr>                    <td>關鍵詞:</td>                    <td><input class="easyui-textbox" type="text" name="keywords" data-options="" style="width:200px"></input></td>                </tr>            </table></form>

springMVC 設定檔

 <!-- SpringMVC上傳檔案時,需要配置MultipartResolver處理器 -->      <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">          <property name="defaultEncoding" value="UTF-8"/>          <!-- 指定所上傳檔案的總大小不能超過200KB。注意maxUploadSize屬性的限制不是針對單個檔案,而是所有檔案的容量之和 -->          <property name="maxUploadSize" value="200000"/>      </bean>            <!-- SpringMVC在超出上傳檔案限制時,會拋出org.springframework.web.multipart.MaxUploadSizeExceededException -->      <!-- 該異常是SpringMVC在檢查上傳的檔案資訊時拋出來的,而且此時還沒有進入到Controller方法中 -->      <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">          <property name="exceptionMappings">              <props>                  <!-- 遇到MaxUploadSizeExceededException異常時,自動跳轉到/WEB-INF/jsp/error_fileupload.jsp頁面 -->                  <prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">error_fileupload</prop>              </props>          </property>      </bean>  

model

public class BrandModel {private Integer id;private String name;private String description;private String url;private String icon;private MultipartFile sourceFile; //對應<span style="font-family: Arial, Helvetica, sans-serif;"><input class="easyui-filebox" name="sourceFile" style="width:200px"></span>        //set/get}

service 複製到你自己的目錄

FileUtils.copyInputStreamToFile(brandModel.getSourceFile().getInputStream(), new File(targetPath));  





springMVC 返回json資料 前台jquery easyui 接受json卻提示 下載updateaction

struts裡面出現這種情況是在配置裡面加上 如下配置: <param name="contentType">text/html</param>

spring應該也類似吧...
 
為何我使用easyui與springmvc+hibernate+spring一起使用,easyui不起作用,我引的easyui的js路徑對的,

easyui怎麼還是jar包 啊?怎麼還放到lib下啊?easyui是js,跟jquery一樣用,用的時候在jsp頁面先引入jquery(必須),再引入easyui相關的js和css檔案。
<link rel="stylesheet" type="text/css" href="../css/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../css/icon.css">
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.