zoukankan      html  css  js  c++  java
  • 在myeclipse中使用./和../遇到的问题

    今天用ajax验证的时候,ajax的代码一直不起作用,我在浏览器里打开了开发者模式,错误的原因是找不到"jquery-1.8.3.min.js",但是我的目录结构都没有问题。

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

    新建的jsp页面开头都会有这样的语句,并且下面还会有一句

    <base href="<%=basePath%>">

    这些代码的作用是,让你的jsp页面就在项目的根目录下。我做了以下测试:

     

    <%@ page language="java" 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 'test.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>
       <%=basePath%>
      </body>
    </html>

    其实在myeclipse里,新建的jsp页面,在basePath之后应该接着写,把路径补充完整。比如在上面的测试中,我的就应该加上“innovativePlatform/test/test/”

    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/innovativePlatform/test/test/";
  • 相关阅读:
    快速幂 快速乘法
    扩展欧几里得学习笔记
    求逆序数数目(树状数组+离散化)
    隐式图的遍历
    随机数生成
    推倒重来
    动态规划初步
    子集生成
    东大oj1155 等凹函数
    P1278 单词游戏
  • 原文地址:https://www.cnblogs.com/w-honey/p/9614352.html
Copyright © 2011-2022 走看看