javaweb 项目中 求 basePath中的方法

首先 我们建一个basePathFilter

public class BasePathFilter implements Filter{



public void destroy() {
// TODO Auto-generated method stub

}


public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) arg0;
String prjPath = request.getScheme() + "://" + request.getServerName() + (request.getServerPort() == 80 ? "" : ":" + request.getServerPort()) + request.getContextPath();
request.setAttribute("basePath", prjPath);
arg2.doFilter(arg0, arg1);

}


public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub

}


}

2 然后再web.xml添加过滤器  


    basePathFilter
    com.rf.sys.filter.BasePathFilter
 

 
    basePathFilter
    /*
 


3然后我们可以页面活其他地方引用了




<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/inc/head.jsp"%>


运输工具单一窗口(客线)







你可能感兴趣的:(utils)