轻松路径 JBoss
我在本地主机上使用 Resteasy 2.1 导航到我的 Restful 服务时遇到问题,希望这里有人能够帮助我。
我已经构建了一个 EAR 文件,里面有 WAR,似乎可以编译并部署到 JBoss5。
我的服务简化了:
@Path("RequestReply")
public class Replier {
@GET
@Path("request")
public String getReply(@QueryParam("id") @DefaultValue("") String id){
if (id.length > 0){
return "ACK";
}
return "NACK";
}
}
我的 web.xml 文件是标准的:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<display-name>Test service</display-name>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
所以我尝试使用访问我的 API
但我得到 404错误。
谁能告诉我我做错了什么?
应用程序.xml:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="java.sun.com/xml/ns/javaee"; xmlns:xsi="w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="java.sun.com/xml/ns/javaee java.sun.com/xml/ns/javaee/application_5.xsd"; version="5">
<display-name>Reseasy</display-name>
<module>
<java>simple.jar</java>
</module>
</application>
I am having trouble navigating to my restful service using resteasy 2.1 on localhost and was hoping someone here might be able to help me.
I have built an EAR file with a WAR inside and is seems to compile and deploy to JBoss5 ok.
My service simplified:
@Path("RequestReply")
public class Replier {
@GET
@Path("request")
public String getReply(@QueryParam("id") @DefaultValue("") String id){
if (id.length > 0){
return "ACK";
}
return "NACK";
}
}
My web.xml file is standard:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<display-name>Test service</display-name>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
So I try to access my API using
But I get 404 errors.
Can anyone tell me what I am doing wrong?
Application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="java.sun.com/xml/ns/javaee"; xmlns:xsi="w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="java.sun.com/xml/ns/javaee java.sun.com/xml/ns/javaee/application_5.xsd"; version="5">
<display-name>Reseasy</display-name>
<module>
<java>simple.jar</java>
</module>
</application>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我建议尝试如下操作:
这里 Replier.war 指的是您创建的 WAR 文件的名称,/api 指的是您的请求 URL 的基础。所以它应该看起来像:
试一试吧!
Ok so I would suggest trying something like:
Here the Replier.war refers to the name of the WAR file you create and /api refers to the base of your request URL. So it should look like:
Give that a shot!