Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文件列表访问 #4

Open
ayanami9911 opened this issue May 26, 2021 · 3 comments
Open

文件列表访问 #4

ayanami9911 opened this issue May 26, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@ayanami9911
Copy link

  • 1无法上传文件:http://localhost:8080/sims/uploadServlet 界面显示空白

  • 2.导致文件列表访问报错
    严重 [http-nio-8080-exec-2] org.apache.catalina.core.StandardWrapperValve.invoke 在路径为[/sims]的上下文中,servlet[web.servlet.file.FileListServlet]的Servlet.service()引发异常
    java.lang.NullPointerException
    HTTP状态 500 - 内部服务器错误
    类型 异常报告

描述 服务器遇到一个意外的情况,阻止它完成请求。

例外情况

java.lang.NullPointerException
web.servlet.file.FileListServlet.doPost(FileListServlet.java:28)
web.servlet.file.FileListServlet.doGet(FileListServlet.java:56)
javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

@rawchen
Copy link
Owner

rawchen commented May 26, 2021

已push正确文件 FileListServlet.java
具体原因是部署并运行时该项目时候out目录没有自动创建upload文件夹,在点击文件列表菜单时执行File[] arrs = dir.listFiles();时发现该dir为Null空指针异常,我并没有做判空并创建文件夹处理,因此报错,现已修正。

@rawchen rawchen added the bug Something isn't working label May 26, 2021
@ayanami9911
Copy link
Author

  • 感谢。

  • FileListServlet.java修改后,现可查看文件列表,但文件上传仍有一些问题,上传文件时点button后进入servlet就显示一片空白。退回查看文件列表可显示文件信息(但文件大小显示为0B)

  • 下载文件时报错。

@rawchen
Copy link
Owner

rawchen commented May 26, 2021

image
修复成功,具体原因看图。
UploadServlet.java中那个File应该先实例化文件夹upload,判断不是空才write到一个File文件的实例。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants