Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/387.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 HTTP状态500-实例化servlet类com.DataFetch时出错_Java_Servlet 3.0 - Fatal编程技术网

Java HTTP状态500-实例化servlet类com.DataFetch时出错

Java HTTP状态500-实例化servlet类com.DataFetch时出错,java,servlet-3.0,Java,Servlet 3.0,我的web.xml文件中有以下代码。我正在Tomct服务器上运行我的项目。我面临以下错误: 类型异常报告消息实例化servlet类com.DataFetch时出错 说明服务器遇到内部错误,无法满足此请求 还有我的web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xs

我的web.xml文件中有以下代码。我正在Tomct服务器上运行我的项目。我面临以下错误:

类型异常报告消息实例化servlet类com.DataFetch时出错 说明服务器遇到内部错误,无法满足此请求

还有我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <display-name>firstServletJsp</display-name>
  <servlet>
    <servlet-name>fetch</servlet-name>
    <servlet-class>com.DataFetch</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>fetch</servlet-name>
    <url-pattern>/sh</url-pattern>
  </servlet-mapping>

</web-app>

firstServletJsp
取来
com.DataFetch
取来
/嘘

将web.xml放入WebContent>web-INF文件夹并重建项目。和示例web.xml代码:-

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>SecureCloud</display-name>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
    <servlet-name>fetch</servlet-name>
    <servlet-class>com.DataFetch</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>fetch</servlet-name>
    <url-pattern>/sh</url-pattern>
</servlet-mapping>
</web-app>

安全云
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
取来
com.DataFetch
取来
/嘘

您的项目似乎没有正确构建并部署到tomcat中。你用什么来部署你的项目?我被手动复制了我的应用程序文件夹并复制到了webapps文件夹中。你能在你的问题上写下你的应用程序文件夹结构吗?apache-tomcat-7.0.73\webapps\webapps\ReadJson\WEB-INF\classes\DataFetch.javaapache-tomcat-7.0.73\webapps\ReadJson\WEB-INF\WEB.XML这与他的问题无关,而且这没什么区别。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>SecureCloud</display-name>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
    <servlet-name>fetch</servlet-name>
    <servlet-class>com.DataFetch</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>fetch</servlet-name>
    <url-pattern>/sh</url-pattern>
</servlet-mapping>
</web-app>