Posts

javascript and thymeleaf

  th:each  in Thymeleaf is primarily used for iterating over collections within HTML templates, not directly within JavaScript code.  It processes on the server-side to generate HTML before the JavaScript executes in the browser.  However, you can use  th:each  to generate JavaScript code dynamically based on data from your server.  Here's how: Generating JavaScript with  th:each Server-Side Iteration:   Use  th:each  within a  <script>  tag to loop through a collection provided by your Spring Boot controller. Code < script th:inline= "javascript" > /*<![CDATA[*/ var items = []; /*[# th:each= "item : ${itemList}" ]*/ items.push(/*[[${item}]]*/); /*[/]*/ console.log(items); /*]]>*/ </ script > th:inline="javascript" : Enables Thymeleaf to process the script tag. /*<![CDATA[*/  and  /*]]>*/ : Wraps the JavaScript code...

hide and show div tag in JS

**  Setting the display property of an element only changes  how the element is displayed , NOT what kind of element it is. So, an inline element with  display: block;  is not allowed to have other block elements inside it. The  display  property is used to specify how an element is shown on a web page. Every HTML element has a default display value, depending on what type of element it is. The default display value for most elements is  block  or  inline . The   display   property is used to change the default display behavior of HTML elements. display: none;  is commonly used with JavaScript to hide and show elements without deleting and recreating them. visibility:hidden;  also hides an element. However, the element will still take up the same space as before. The element will be hidden, but still affect the layout: Example h1.hidden  {   visibility :  hidden ; }       <!DOCTYPE htm...

Standard URL Syntax

  Standard URL Syntax The Thymeleaf standard dialects –called  Standard  and  SpringStandard – offer a way to easily create URLs in your web applications so that they include any required  URL preparation  artifacts. This is done by means of the so-called  link expressions , a type of  Thymeleaf Standard Expression :  @{...} Absolute URLs Absolute URLs allow you to create links to other servers. They start by specifying a protocol name ( http://  or  https:// ) < a th: href = " @{http://www.thymeleaf/documentation.html} " > They are not modified at all (unless you have an  URL Rewriting  filter configured at your server and performing modifications at the  HttpServletResponse.encodeUrl(...)  method): < a href = " http://www.thymeleaf/documentation.html " > Context-relative URLs The most used type of URLs are  context-relative  ones. These are URLs which are supposed to be relative to the w...