jsp客户端跳转 绝对路径

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>

<%

  String path = request.getContextPath();

  String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

 <base href="<%=basePath%>"> <!--使用绝对路径,在每个访问路径前面自动加上 basePath-->

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

</head>

<body>

    <table  width="100%" border="1" bordercolor="blue">

      <tr>

        <td align="center" height="40">

          <html:link forward="customerRegister">用户注册</html:link>

        </td>

      </tr>

      <tr>

        <td align="center" height="40"">

          <html:link forward="customerInfoSearch">用户信息查询</html:link>

        </td>

      </tr>

    </table>

</body>

</html>

你可能感兴趣的:(绝对路径)