zoukankan      html  css  js  c++  java
  • thymeleaf 获取项目路径

    <p th:text=${salecode}></p>
    
    <a th:href="${#httpServletRequest.getScheme()+'://'+#httpServletRequest.getServerName()+':'+#httpServletRequest.getServerPort()+#httpServletRequest.getContextPath()+'/icon/'+salecode } "
    ></a>

    效果图如下:

    插入一段本地不需要加上项目名称,在正式环境下服务器下需要加上项目名称的判断,免得本地和服务器上都改来改去,有时候忘记改了,就gg了:

    <a class="item" th:each="taopiao,u : ${list}" th:if="${#httpServletRequest.getServerPort()} ne 8080" th:href="'/fastbuytickets/purchase?id='+${taopiao.productId}">
            服务器调测
    </a>
    <a class="item" th:each="taopiao,u : ${list}" th:if="${#httpServletRequest.getServerPort()} eq 8080" th:href="'/purchasetest?id='+${taopiao.productId}">
            本地调测
    </a>

    自己当笔记用,不给坏人用

  • 相关阅读:
    用遗传算法解决子集和问题
    XML映射配置文件
    generator插件配置方式使用
    声明
    spring IOC简单分析
    模板模式
    原型模式
    委派模式,策略模式
    单例模式2
    单例模式
  • 原文地址:https://www.cnblogs.com/1246447850qqcom/p/9714869.html
Copyright © 2011-2022 走看看