[英]No webpage was found for the web address using RestEasy
I am trying to create a sample REST service using RestEasy.我正在尝试使用 RestEasy 创建示例 REST 服务。 Below is my Java class下面是我的 Java 类
@Path("/message")
public class MessageRestService {
@GET
@Path("/{param}")
public Response getMessage(@PathParam("param")String msg){
String result = "Hello World "+msg;
return Response.status(200).entity(result).build();
}
}
My web.xml
is like below我的web.xml
如下所示
<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">
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!-- this need same with resteasy servlet url-pattern -->
<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>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>
index.html
</welcome-file>
</welcome-file-list>
</web-app>
The RestEasy version I am using is 3.0.12.我使用的 RestEasy 版本是 3.0.12。 When I hit the URL like below当我点击下面的网址时
http://localhost:8080/RestPathAnnotationExample/rest/message/test
This localhost
page can't be found.找不到此localhost
页面。
No webpage was found for the web address: http://localhost:8080/RestPathAnnotationExample/rest/message/test
I am deploying on Tomcat 8.我正在 Tomcat 8 上部署。
You specified both resteasy.servlet.mapping.prefix=/rest
and您指定了resteasy.servlet.mapping.prefix=/rest
和
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
that will use mapping on the specified path.将在指定路径上使用映射。 It should work unless you give a correct configuration.除非您提供正确的配置,否则它应该可以工作。 You can learn more about installation and configuration .您可以了解有关安装和配置的更多信息。
RESTeasy is configured by default to scan jars and classes within these directories for JAX-RS annotated classes and deploy and register them within the system.默认情况下,RESTeasy 配置为扫描这些目录中的 jar 和类以查找 JAX-RS 注释类,并在系统中部署和注册它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.