我已经创建了 Openshift 应用程序,现在我正在尝试对其进行编辑。这是项目结构:
http://my.jetscreenshot.com/demo/20130525-t2mt-28kb
我已将此代码添加到 index.html 中:
<form action="/uploadFile" enctype="multipart/form-data" method="post">
<input type="file" name="uploadFile" />
<input type="submit" />
</form>
最后我创建了 servlet 文件 fileUploader.java:
package main.java;
import *;
@WebServlet(name = "uploadFile",urlPatterns = {"/uploadFile"})
@MultipartConfig
public class fileUploader extends javax.servlet.http.HttpServlet {
//class code
}
你可以在这里看到@WebServlet 注释,我读到它足够了,但是它不起作用(404 错误),所以我在 web.xml 中添加了代码:
<servlet>
<servlet-name>uploadFile</servlet-name>
<servlet-class>main.java.fileUploader</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>uploadFile</servlet-name>
<url-pattern>/uploadFile</url-pattern>
</servlet-mapping>
index.html 有效,但 servlet 无效。它现在给出了 500 错误:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Wrapper cannot find servlet class main.java.fileUploader or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:722)
root cause
java.lang.ClassNotFoundException: main.java.fileUploader
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
我对这个问题进行了研究,但我仍然不知道问题出在哪里