Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从war solaris服务器访问windows文件系统?_Java_Spring Mvc_Solaris_Weblogic 10.x - Fatal编程技术网

Java 如何从war solaris服务器访问windows文件系统?

Java 如何从war solaris服务器访问windows文件系统?,java,spring-mvc,solaris,weblogic-10.x,Java,Spring Mvc,Solaris,Weblogic 10.x,我需要从solaris服务器访问windows的文件系统或路径txt文件。我在服务器weblogic solaris中部署了.war,但我无法将txt文件从服务器发送到客户端,在本例中是windows系统或任何系统 对txt文件的访问来自 <input type="file" name="filename" /> 我需要从客户端读取文件,但我遇到了FileNotFoundException 请帮助我您的服务器上运行的Spring MVC应用程序无法访问客户端计算机上的原始文件

我需要从solaris服务器访问windows的文件系统或路径txt文件。我在服务器weblogic solaris中部署了.war,但我无法将txt文件从服务器发送到客户端,在本例中是windows系统或任何系统

对txt文件的访问来自

<input type="file" name="filename" />

我需要从客户端读取文件,但我遇到了FileNotFoundException


请帮助我

您的服务器上运行的Spring MVC应用程序无法访问客户端计算机上的原始文件(否则网站可能会对您的计算机造成不良影响)-浏览器会通过网络将文件的副本发送到控制器

下面是我用来将上传的文件复制到服务器文件系统的代码片段:

@RequestMapping(value = "/upload", method = RequestMethod.POST)
public String uploadFile(
    HttpServletResponse response,
    @RequestParam(value="filename", required=true) MultipartFile multipartFile,
    Model model) throws Exception {

    if (!multipartFile.isEmpty()) {
        String originalName = multipartFile.getOriginalFilename();
        final String baseTempPath = System.getProperty("java.io.tmpdir"); // use System temp directory
        String filePath = baseTempPath + File.separator + originalName;
        File dest = new File(filePath);

        try {
            multipartFile.transferTo(dest); // save the file
        } catch (Exception e) {
            logger.error("Error reading upload: " + e.getMessage(), e);
            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "File uploaded failed: " + originalName);
        }
    }
}

在服务器上运行的Spring MVC应用程序无法访问客户端计算机上的原始文件(否则网站可能会对您的计算机造成不良影响)-浏览器会通过网络将文件副本发送到控制器

下面是我用来将上传的文件复制到服务器文件系统的代码片段:

@RequestMapping(value = "/upload", method = RequestMethod.POST)
public String uploadFile(
    HttpServletResponse response,
    @RequestParam(value="filename", required=true) MultipartFile multipartFile,
    Model model) throws Exception {

    if (!multipartFile.isEmpty()) {
        String originalName = multipartFile.getOriginalFilename();
        final String baseTempPath = System.getProperty("java.io.tmpdir"); // use System temp directory
        String filePath = baseTempPath + File.separator + originalName;
        File dest = new File(filePath);

        try {
            multipartFile.transferTo(dest); // save the file
        } catch (Exception e) {
            logger.error("Error reading upload: " + e.getMessage(), e);
            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "File uploaded failed: " + originalName);
        }
    }
}

你找到stacktrace了吗?您知道
java.io.tmpdir
在您的服务器文件系统中的哪个位置(文件将保存到哪个位置)?你在调试器中运行过它吗?你得到stacktrace了吗?您知道
java.io.tmpdir
在您的服务器文件系统中的哪个位置(文件将保存到哪个位置)?您在调试器中运行过它吗?您需要给我们一些代码:表单的HTML/JSP和表单提交时触发的Spring控制器代码。您需要给我们一些代码:表单的HTML/JSP和表单提交时触发的Spring控制器代码。