jsp頁面的簡單配置使用,和跳轉

request 的常用方法:

request.getSchema()可以返回當前頁面使用的協議,http 或是 https;

request.getServerName()可以返回當前頁面所在的服務器的名字;
request.getServerPort()可以返回當前頁面所在的服務器使用的端口,就是80;

request.getContextPath()可以返回當前頁面所在的應用的名字;


1.主的索引頁面。

<%@page import="com.pay996.oil.service.impl.RiskTerminalServiceImpl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <base href="<%=basePath%>">
    <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
  </head>
  
  <body>
    <a href="risk/findUser.jsp">用戶列表推送</a><br>
    <a href="risk/subscribeCapital.jsp">訂閱資金請求</a><br>
    <a href="risk/unSubscribeCapital.jsp">退訂資金請求</a><br>
    <a href="risk/subscribeOrderInfo.jsp">訂閱報單請求</a><br>
    <a href="risk/unSubscribeOrderInfo.jsp">退訂報單請求</a><br> 
    <a href="risk/subscribePosition.jsp">訂閱持倉請求</a><br>
    <a href="risk/unSubscribePosition.jsp">退訂持倉請求</a><br>
    <a href="risk/modifyAccount.jsp">強平</a><br>
    <a href="javascript:window.history.go(-1);">返回</a>
  </body>

</html>


2. 根據索引頁面中的標籤,點擊,跳轉到其他頁面

<%@page import="com.pay996.oil.service.impl.RiskTerminalServiceImpl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'index.jsp' starting page</title>
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">    
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  <!--
  <link rel="stylesheet" type="text/css" href="styles.css">
  -->
  </head>
  <body>
    This is my JSP page. <br>
        <form action="<%=basePath%>/risk/findUser.shtml" method="from">
      <input type="submit" value="用戶請求" style="height: 35px; ">
    </form>
    <a href="javascript:window.history.go(-1);">返回</a>
  </body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章