0
我已经花了几个小时就解决以下问题:HTTP状态404 - 找不到相关的资源:完整路径:的RESTEasy
我有一个Maven项目具有以下的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>xy</display-name>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<!-- Auto scan REST service -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!-- this should be the same URL pattern as the servlet-mapping property -->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>
<listener>
<listener-class> org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
</web-app>
我的Java类,如下所示:
@Path("/file")
public class File
{
@POST
@Path("/upload")
@Consumes("multipart/form-data")
public Response uploadFile(@MultipartForm Multipart form) {}
后项目 - >运行方式 - >服务器上运行显示正确的index.jsp。
当我点击一个按钮,上传文件出现错误:
HTTP状态404 - 相对找不到资源:/文件/上传完整路径:http://localhost:8080/Projectname/rest/file/upload
我已位于做到:
- 清洁工程
- 更新的Maven
- 运行方式 - > Maven的 - >全新安装(建sucess)
- 删除Tomcat和重新安装它
- 禁用自动扫描并添加“文件”手动
而且我得到警告说,一些罐子不能可以在Tomcat路径中找到(/Tomcat8/wtpwebapps/Projectname/WEB-INF/lib/activation-1.1.jar(没有这样的文件或目录 - 但它可以在pom.xml和target-> Projectname-> WEB -INF-> lib)
我用resteasy-jaxrs 2.2.1.GA
我很感激任何帮助:)