zoukankan      html  css  js  c++  java
  • struct相对路径,绝对路径

    Action result

    加'/'  不用加项名 重定向具体页面

    不加'/'  一般是提交的连接去掉'/' 用在redirectAction

    html,jsp等web界面中 路径主要分为两种:相对路径,绝对路径

    主要用在两个地方

    1.<a  href="xx"></a> <form action="xx">  表单和超链接中

    2.引用外部资源 如图片,外部链接,引用css,js等

    第一种情况

    <a>,<form>这两个html标签 既可以用绝对路径,也可以用相对路径

    1)绝对路径 写法   <a href="/ssh/xxx.jsp'></a>  <form action="/ssh/xxx.action'>

    2)相对路径写法    <a href="xxx.jsp'></a>  <form action="xxx.action'> 这种写法也行但是不推荐  原理:请求地址 是根据当前页面的地址决定的

    <a href="123"></a>

    1 http://localhost:8080/springmvc1/helloworld页面地址下 

    链接地址为  http://localhost:8080/springmvc1/123

    2  http://localhost:8080/springmvc1/springmvc/helloworld页面地址下

    连接地址为 http://localhost:8080/springmvc1/springmvc/123 

     http://www.cnblogs.com/gtaxmjld/p/4230482.html

    不加"/" 相对于当前页面请求地址  

    加"/" 相对于服务器根目录下地址

    为了不混淆 :别用basePath 也别用相对路径 如果是转发到当前页面,会改变路径

    如转发到http://localhost:8080/springmvc1/springmvc 

    <a href="spring/helloworld"></a>  原来是http://localhost:8080/springmvc1/springmvc/helloworld  现在变成了http://localhost:8080/springmvc1/springmvc/springmvc/helloworld 解决办法用1.<s:a>标签2.<%=request.getContextPath%>/3.${pageContext.request.contextPath}

    总结:相当于自动加上了basePath

    <s:a>,<s:form>这两个structs2标签  

    没有相对路径,只有绝对路径

    绝对路径写法两种

    1)<s:a href="/ssh/xx"> <s:from action="/ssh/xx">   structs2标签的.action是可以省略的

    2)<s:a action="${pageContext.request.contextPath}/xx">(href和action属性都可以用)     <s:form action="${pageContext.request.contextPath}/xx"></s:form>  

    其中${pageContext.request.contextPath}是可以省略的   变成了====><s:a action=""xx"></s:a> structs2 的.action都是可以省略的(会自动加上的),且会自动加上${pageContext.request.contextPath}/

    <form>表单默认method=get

    <s:form>逼单默认method=post

    外部资源一定,坑定是要用绝对路径的 不然 当工作空间改变时,所有的路径都要修改,很麻烦.

    固定写法::::<script language="javascript" src="${pageContext.request.contextPath}/script/PageUtils.js" charset="utf-8"></script>

  • 相关阅读:
    什么叫继承?
    两类交换元素使序列有序 求最少交换次数的题
    如何理解汉诺塔
    求给出第 K个 N位二进制数,该二进制数不得有相邻的“1”
    7/26 CSU-ACM2018暑期训练3-递归&递推-选讲
    平面分割
    递推算法之平面分割问题总结
    UTC时间
    7/25 CSU-ACM2018暑假集训比赛1
    洛谷 P1824 进击的奶牛【二分答案/类似青蛙过河】
  • 原文地址:https://www.cnblogs.com/lt123/p/7388054.html
Copyright © 2011-2022 走看看