zoukankan      html  css  js  c++  java
  • Jsp动态页面关于IDE默认添加的语句的说明

    当新建Web Project后,在WebRoot中IDE自动生成的index.jsp。index.jsp默认生成的代码内容中:

     1 <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
     2 <%
     3 String path = request.getContextPath();
     4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
     5 %>
     6 
     7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     8 <html>
     9   <head>
    10     <base href="<%=basePath%>">
    11     
    12     <title>My JSP 'index.jsp' starting page</title>
    13     <meta http-equiv="pragma" content="no-cache">
    14     <meta http-equiv="cache-control" content="no-cache">
    15     <meta http-equiv="expires" content="0">    
    16     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    17     <meta http-equiv="description" content="This is my page">
    18     <!--
    19     <link rel="stylesheet" type="text/css" href="styles.css">
    20     -->
    21   </head>
    22   
    23   <body>
    24     This is my JSP page. <br>
    25   </body>
    26 </html>

    需要解释第3行,第4行和第10行。

    第3行为request.getContextPath(),是你的新建时指定的工程名。这个名字是部署到服务器上的名字。

    第4行为request.getScheme()得到协议的内容(例如Http),request.getServerName()得到服务器的域名(IP地址也可),request.getServerPort()得到服务器的端口号,而最后的path即为第3行的request.getContextPath(),得到部署在服务器上的工程名。

    再看一下第4行的代码,中间的连接字符,举个例子给你做个对比你就知道啥意思了,http://127.0.0.1:8080/kantai/

    第10行代码的意思是假如你在index.jsp页面有一个aaa.html超链接,那你点击超链接的时候要访问的地址是http://127.0.0.1:8080/kantai/aaa.html,你明白了吧。

    待更新。。。。。。。。。

  • 相关阅读:
    linux read的用法[转]
    1>/dev/null 2>&1的含义
    文件的权限
    【原创】server 10.192.242.184 not responding, still trying
    git使用中遇到的错误及解决方法
    linux中mmu作用的简单总结(未完)
    python版本设置
    【转】buntu TELNET服务安装配置
    【转】进程上下文和中断上下文、原子上下文的区别
    【转】【Linux】理解bitops中的__set_bit及其应用
  • 原文地址:https://www.cnblogs.com/yzyqqhr/p/5769961.html
Copyright © 2011-2022 走看看