zoukankan      html  css  js  c++  java
  • 在jsp页面如果运行时路径错误解决方法

    <%
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <base href="<%=basePath%>">
    例如:
    <%--
      Created by IntelliJ IDEA.
      User: Administrator
      Date: 2019/6/5
      Time: 15:02
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <html>
    <link rel="stylesheet" href="css/style.css">
    <head>
        <base href="<%=basePath%>">
        <title>Title</title>
    </head>
    <script src="script/jquery-1.8.3.js"></script>
    <script>
       $(function(){
           //为所有的删除的超链接增加单击事件
           $(".delete").click(function(){
               //获取到超链接的请求的href的路径
               var href=$(this).attr("href");
               //把form的action属性设置成href
               $("form").attr("action",href);
               //提交表单
               $("form").submit();
               //阻止原来的单机事件
               return false;
           });
       });
    </script>
    <body>
    <form action="" method="post">
        <input type="hidden" name="_method" value="DELETE"/>
    </form>
    <table border="1">
        <tr>
            <td colspan="5">
                查看所有部门
            </td>
        </tr>
        <tr>
            <th>部门编号</th>
            <th>部门名称</th>
            <th>部门位置</th>
            <th>表操作</th>
        </tr>
    
        <c:forEach items="${depts}" var="dept">
            <tr>
                <td>${dept.deptno}</td>
                <td>${dept.dname}</td>
                <td>${dept.loc}</td>
                <td>
                   <a href="delete/${dept.deptno}" class="delete">删除</a>
                   <a href="toUpdate/${dept.deptno}">修改</a>
                </td>
            </tr>
        </c:forEach>
        <tr>
            <td colspan="5">
            <a href="toSave">添加部门</a>
            </td>
        </tr>
    
    </table>
    
    </body>
    </html>
  • 相关阅读:
    2015.10.9js(页面坐标)
    2015.8.2js-19(完美运动框架)
    2015.7.12js-11(DOM基础)
    2015.7.7js-07-2(基础)
    2015.7.11js-10(无缝滚动)
    2015.7.10js-07(简单时间)
    2015.7.8js-05(简单日历)
    2015-7.7森林探秘季
    jquery scroll()滚动条事件
    资源(127.0.0.1)处于联机状态,但未对连接尝试做出反应
  • 原文地址:https://www.cnblogs.com/qurui1998/p/10998786.html
Copyright © 2011-2022 走看看