保存进度!
This commit is contained in:
parent
66b911ab6a
commit
655e856ad9
@ -2,7 +2,7 @@
|
||||
* @Author: Kane
|
||||
* @Date: 2022-09-28 15:47:02
|
||||
* @LastEditors: Kane
|
||||
* @LastEditTime: 2022-09-28 23:04:17
|
||||
* @LastEditTime: 2022-09-29 00:07:31
|
||||
* @FilePath: \car_dealer\src\main\java\com\cpic\xim\car_dealer\controllers\fileupload\FileUploadController.java
|
||||
* @Description:
|
||||
*
|
||||
@ -12,20 +12,21 @@
|
||||
package com.cpic.xim.car_dealer.controllers.fileupload;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.channels.IllegalSelectorException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Controller
|
||||
@Scope( "session" )
|
||||
public class FileUploadController
|
||||
{
|
||||
@RequestMapping( value = "/test")
|
||||
@RequestMapping( value = "/test" )
|
||||
public void test() throws ServletException, IOException
|
||||
{
|
||||
// PrintWriter writer = response.getWriter();
|
||||
@ -33,21 +34,27 @@ public class FileUploadController
|
||||
// writer.write( "测试!" );
|
||||
}
|
||||
|
||||
@RequestMapping( "/upload")
|
||||
public void uploadFile( HttpServletRequest request, HttpServletResponse response,
|
||||
MultipartFile file, Model model ) throws IllegalSelectorException, IOException
|
||||
@RequestMapping( path = "/upload" )
|
||||
@ResponseBody
|
||||
public FileUploadResult uploadFile( HttpServletRequest request, HttpServletResponse response,
|
||||
MultipartFile file ) throws IllegalSelectorException, IOException
|
||||
{
|
||||
response.setContentType( "text/json;charset=UTF-8" );
|
||||
PrintWriter writer = response.getWriter();
|
||||
|
||||
FileUploadResult result = new FileUploadResult();
|
||||
// PrintWriter writer = response.getWriter();
|
||||
// String sessionID = request.getSession().getId();
|
||||
|
||||
if ( file == null)
|
||||
{
|
||||
writer.write( "{\"message\":\"提交方式有误!\"}" );
|
||||
result.setSuccess( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.write( file.getOriginalFilename() );
|
||||
|
||||
result.setSuccess( true );
|
||||
result.setFilePath( file.getOriginalFilename() );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2022-09-28 23:43:42
|
||||
* @LastEditors: Kane
|
||||
* @LastEditTime: 2022-09-29 00:01:04
|
||||
* @FilePath: \car_dealer\src\main\java\com\cpic\xim\car_dealer\controllers\fileupload\FileUploadResult.java
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.cpic.xim.car_dealer.controllers.fileupload;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class FileUploadResult
|
||||
{
|
||||
@JsonProperty( "is_success" )
|
||||
private boolean isSuccess;
|
||||
|
||||
@JsonProperty( "file_path" )
|
||||
private String filePath;
|
||||
|
||||
public FileUploadResult()
|
||||
{}
|
||||
|
||||
public boolean getIsSuccess()
|
||||
{
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
public void setSuccess( boolean isSuccess )
|
||||
{
|
||||
this.isSuccess = isSuccess;
|
||||
}
|
||||
|
||||
public String getFilePath()
|
||||
{
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath( String filePath )
|
||||
{
|
||||
this.filePath = filePath;
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user