【问题标题】:Thymeleaf problems css?Thymeleaf问题css?
【发布时间】:2015-10-11 17:57:28
【问题描述】:

我正在使用这个库thymeleaf-layout-dialect

我的布局方言....

        <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
    <head>
          <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
          <title layout:title-pattern="$DECORATOR_TITLE - $CONTENT_TITLE">NextInfo</title>
          <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
          <link rel="stylesheet" type="text/css" href="../../../resources/css/animate.css" th:href="@{'resources/css/animate.css'}"/>
          <link rel="stylesheet" type="text/css" href="../../../resources/css/semantic.min.css" th:href="@{'resources/css/semantic.min.css'}"/>
    </head>
    <body>
        <div class="ui stackable blue inverted menu">
              <a class="right item ">
                    <i class="home icon"></i>
                    Inicio
                  </a>
                 <a class="item">
                    <i class="phone icon"></i>
                    Telefones
                  </a>
                  <a class="item">
                    <i class="mail Outline icon"></i>
                    Email
                  </a>
                  <a class="item">
                    <i class="chat icon"></i>
                    Suporte
                  </a>
                   <div class="ui category search item" style="margin-right:40px">
                    <div class="ui transparent icon input">
                      <input class="prompt" type="text" placeholder=" pesquisar ..." />
                      <i class="search link icon"></i>
                    </div>
                    <div class="results"></div>
                </div>
        </div>
        <div id="header" layout:fragment="header"></div>
        <div id="content" layout:fragment="content"></div>
        <div id="footer" layout:fragment="footer"></div>
        <script src="../../../resources/js/jquery.min.js" data-th-src="@{resources/js/jquery.min.js}"></script>
        <script src="../../../resources/js/semantic.min.js" data-th-src="@{resources/js/semantic.min.js}"></script>
    </body>
    </html>

我创建了一个布局,如链接所示

我的家庭控制器

@Controller
@RequestMapping(value ={"/","/home"})
public class Principal {

private final static String URLINICIAL = "index";

@RequestMapping(value ={"/","/home"} ,method=RequestMethod.GET)
public String requisicaoPadrao() {
    return URLINICIAL;
}
@ResponseBody
@RequestMapping(value = "/testes", method=RequestMethod.GET)
public <T> Object testes() {
    return null;
}
}

index.html

    <html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"  layout:decorator="/templates/layouts/default">
  <head>

  </head>
<body>
 <div layout:fragment="header"><h1>index</h1></div>
 <div layout:fragment="content"></div>
</body>
</html>

创建新视图

    <html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"  layout:decorator="/templates/layouts/default">
  <head>
    <title>testPage</title>
  </head>
<body>
<h1>teste</h1>
     <div layout:fragment="header"><h1>testPage</h1></div>
     <div layout:fragment="content"></div>
</body>
</html>

新控制器
我需要类上方的@RequestMapping注解。

    @Controller
    @RequestMapping("/test")
    public class TestController {

        @RequestMapping(value = "/", method=RequestMethod.GET)
        public String index(){
            return "testpage";
        }

    }

如您所见,它不起作用.... 如何解决?

【问题讨论】:

    标签: html css spring-mvc thymeleaf


    【解决方案1】:

    我设法解决了这个问题
    &lt;script src="../../../resources/js/jquery.min.js" data-th-src="@{resources/js/jquery.min.js}"&gt;&lt;/script&gt;

    <script src="/web/resources/js/lib/jquery.min.js"></script>
    

    我没有使用百里香的具体标签

    【讨论】:

      猜你喜欢
      • 2020-07-18
      • 2017-08-10
      • 2016-04-22
      • 2018-03-22
      • 2019-03-25
      • 1970-01-01
      • 1970-01-01
      • 2017-05-26
      • 2017-06-28
      相关资源
      最近更新 更多