[英]URL path not working in when deployed in WebLogic server
type here在此输入
I am trying to build REST API, I have created the web application project using maven and included jersey dependencies in pom.xml file.我正在尝试构建 REST API,我使用 maven 创建了 web 应用程序项目,并在 pom.xml 文件中包含 jersey 依赖项。 Also I have included web.xml file and weblogic.xml file in web-inf folder.
我还在 web-inf 文件夹中包含了 web.xml 文件和 weblogic.xml 文件。 when deployed and execute the URL path index.jsp is working fine.
当部署并执行 URL 路径 index.jsp 工作正常。 but other URL is not working it show the Not found.
但其他 URL 不工作,它显示未找到。 Unable to find what is wrong.
找不到问题所在。
Web.xml file 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_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>Rest service</display-name>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.vno.testaddress</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
</web-app>
weblogic.xml weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">
<wls:weblogic-version>14.1.1.0</wls:weblogic-version>
<wls:context-root>/address</wls:context-root>
<wls:container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<wls:prefer-application-packages>
<wls:package-name>org.slf4j.*</wls:package-name>
<wls:package-name>org.glassfish.jersey.*</wls:package-name>
<wls:package-name>io.swagger.core.*</wls:package-name>
<wls:package-name>io.swagger.parser.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>
Java code: Java 代码:
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
/**
* Hello world!
*
*/
@Path("myresource")
public class Testaddress
{
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getIt() {
return "Hello world!";
}
}
Error:错误:
I am trying to use this url: http://192.168.77.10:7001/testaddress-0.0.1-SNAPSHOT/webapi/myresource and expecting the result as "Hello World."我正在尝试使用此 url: http://192.168.77.10:7001/testaddress-0.0.1-SNAPSHOT/webapi/myresource并期望结果为“Hello World”。 but it shows not found.
但是显示没有找到。
I see 2 potential issues:我看到 2 个潜在问题:
Let me know让我知道
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.