• 在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/";
  • 相关阅读:
    数据比赛实现的细节
    matlab 构建数据集实用 api
    matlab 构建数据集实用 api
    新技能 get —— 如何校验 md5(windows)
    新技能 get —— 如何校验 md5(windows)
    中间件 —— 消息中间件(MOM)
    中间件 —— 消息中间件(MOM)
    详细说明svn分支与合并---命令行
    SVN 分支及合并的介绍和实践---命令行
    SVN中的Branches分支以及Merge 应用举例
  • 原文地址:https://www.cnblogs.com/w-honey/p/9614352.html
Copyright © 2020-2023  润新知