React Typescript + Spring Boot上传CSV文件

我正在前端使用React Typescript,后端使用Spring Boot。


export const Home: React.FC = () => {
    return (
        <div className="input-container">
            <form className="form-wrapper"  action={"/upload"}  method={"POST"}     encType="multipart/form-data">
                <button className="choose-file" type="button">
                    Choose File
                    <input className="file-input" type="file" name="file" accept={".csv"}/>

                <button className="upload-button" type="submit">


public class File {
    private long id;
    private float lat;
    private float log;

    // getters and setters 


public class FileController {

    public String home() {
        return "index";

    public String GetFile(@RequestParam("file") MultipartFile file, Model model)        {

        //validate file
        if (file.isEmpty()) {
            model.addAttribute("message", "No File Selected, Select CSV file to upload");
            model.addAttribute("status", false);
        } else {
            // parse CSV file to create a table
            try (Reader reader = new BufferedReader((new InputStreamReader(file.getInputStream())))) {

                // create csv bean reader
                CsvToBean<File> csvToBean = new CsvToBeanBuilder(reader)

                // convert CSVbean to table list
                List<File> files = csvToBean.parse();

                // TODO: save file list into db

                // save file list on model
                model.addAttribute("files", files);
                model.addAttribute("status", true);
            } catch (Exception e){
                model.addAttribute("message", "An error occurred while processing the CSV file.");
                model.addAttribute("status", false);
        return file;