补充,上边那个方法实现后出现了一些问题:
配置weblogic.xml上下文根为/之后会隐藏项目名称,导致程序里一部分内容无法显示(由于路径指定的绝对路径,大神们肯定不会这样吧。。)!
解决方法如下:
1.新建一个工程,只写一个jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String ip = (String)request.getSession().getServletContext().getAttribute("ip");
String basePath = request.getScheme()+"://"+ip+":"+request.getServerPort()+path+"/";
request.setAttribute("basePath",basePath);
response.sendRedirect("此处写你的访问地址");
%>
配置weblogic.xml 上下文根为 /
2.配置你原项目weblogic.xml 上下文根为 /项目名称
3.两个工程部署到同意服务下,直接访问http://ip:post 他就会跳转到你写的地址上。