• 大小: 7.62MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-16
  • 语言: Java
  • 标签:

资源简介

SpringMVC上传图片文件到 阿里云,亲测可用。前端使用Ajax。

资源截图

代码片段和文件信息

package com.neusoft.controller;

import com.neusoft.util.OSSClientUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author XiaoLuo
 * @ClassName: UserController
 * @Description: ${todo}
 * @date 2017/9/1 17:57
 */
@Controller
public class UploadController {

@RequestMapping(“/“)
public ModelAndView index() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName(“index“);
return modelAndView;
}

@RequestMapping(“/upload“)
@ResponseBody
public object upload(@RequestParam(“file“) MultipartFile file)throws Exception{
OSSClientUtil ossClient = new OSSClientUtil();
String name = ossClient.uploadImg2Oss(file);
String imgUrl = ossClient.getImgUrl(name);
String[] split = imgUrl.split(“\\?“);
return split[0];
}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        290  2018-04-02 14:56  test-oss\.idea\artifacts\test_oss_war.xml

     文件       3208  2018-04-02 17:14  test-oss\.idea\artifacts\test_oss_war_exploded.xml

     文件        628  2018-04-02 15:02  test-oss\.idea\compiler.xml

     文件        517  2018-04-02 20:29  test-oss\.idea\libraries\Maven__aopalliance_aopalliance_1_0.xml

     文件        597  2018-04-02 20:29  test-oss\.idea\libraries\Maven__commons_beanutils_commons_beanutils_1_8_0.xml

     文件        539  2018-04-02 20:29  test-oss\.idea\libraries\Maven__commons_codec_commons_codec_1_9.xml

     文件        619  2018-04-02 20:29  test-oss\.idea\libraries\Maven__commons_collections_commons_collections_3_2_1.xml

     文件        608  2018-04-02 20:29  test-oss\.idea\libraries\Maven__commons_fileupload_commons_fileupload_1_3_1.xml

     文件        506  2018-04-02 20:29  test-oss\.idea\libraries\Maven__commons_io_commons_io_2_2.xml

     文件        528  2018-04-02 20:29  test-oss\.idea\libraries\Maven__commons_lang_commons_lang_2_5.xml

     文件        561  2018-04-02 20:29  test-oss\.idea\libraries\Maven__commons_logging_commons_logging_1_2.xml

     文件        564  2018-04-02 20:29  test-oss\.idea\libraries\Maven__com_aliyun_oss_aliyun_sdk_oss_2_8_2.xml

     文件        581  2018-04-02 20:29  test-oss\.idea\libraries\Maven__javax_servlet_javax_servlet_api_3_1_0.xml

     文件        497  2018-04-02 20:29  test-oss\.idea\libraries\Maven__javax_servlet_jsp_api_2_0.xml

     文件        525  2018-04-02 20:29  test-oss\.idea\libraries\Maven__javax_servlet_servlet_api_2_4.xml

     文件        465  2018-04-02 20:29  test-oss\.idea\libraries\Maven__junit_junit_3_8_1.xml

     文件        515  2018-04-02 20:29  test-oss\.idea\libraries\Maven__net_sf_ezmorph_ezmorph_1_0_6.xml

     文件        524  2018-04-02 20:29  test-oss\.idea\libraries\Maven__net_sf_json_lib_json_lib_jdk15_2_4.xml

     文件        580  2018-04-02 20:29  test-oss\.idea\libraries\Maven__org_apache_httpcomponents_httpclient_4_4_1.xml

     文件        566  2018-04-02 20:29  test-oss\.idea\libraries\Maven__org_apache_httpcomponents_httpcore_4_4_1.xml

     文件        456  2018-04-02 20:29  test-oss\.idea\libraries\Maven__org_jdom_jdom_1_1.xml

     文件        612  2018-04-02 20:29  test-oss\.idea\libraries\Maven__org_springframework_spring_aop_4_2_4_RELEASE.xml

     文件        626  2018-04-02 20:29  test-oss\.idea\libraries\Maven__org_springframework_spring_beans_4_2_4_RELEASE.xml

     文件        640  2018-04-02 20:29  test-oss\.idea\libraries\Maven__org_springframework_spring_context_4_2_4_RELEASE.xml

     文件        619  2018-04-02 20:29  test-oss\.idea\libraries\Maven__org_springframework_spring_core_4_2_4_RELEASE.xml

     文件        661  2018-04-02 20:29  test-oss\.idea\libraries\Maven__org_springframework_spring_expression_4_2_4_RELEASE.xml

     文件        633  2018-04-02 20:29  test-oss\.idea\libraries\Maven__org_springframework_spring_webmvc_4_2_4_RELEASE.xml

     文件        612  2018-04-02 20:29  test-oss\.idea\libraries\Maven__org_springframework_spring_web_4_2_4_RELEASE.xml

     文件        566  2018-04-02 14:56  test-oss\.idea\misc.xml

     文件        256  2018-04-02 14:56  test-oss\.idea\modules.xml

............此处省略100个文件信息

评论

共有 条评论