Questions tagged [thymeleaf]

1

votes
1

answer
834

Views

Thymeleaf + Spring Security Expression language

I'm trying to fetch the UserDetails object out of Spring Security from Thymeleaf. I have tried various SpEl things, like: ${#authentication.principal.blahblah} I'm trying to assign this to a Javascript variable as: var foo='${#authentication.principal.blahblah}'; I'm using Spring Boot 1.2.5 with the...
alessandro ferrucci
1

votes
2

answer
1.5k

Views

Spring Boot and form Thymeleaf. Accessing object properties from the template

I am currently trying out with Spring Boot, and have developed some smaller CRUD-like applications with Spring Boot and Thymeleaf. Here my controller @Controller public class Home { @RequestMapping(value='/', method=RequestMethod.GET) public String index(Post post) { return 'index'; } @RequestMappin...
Amadeu Cabanilles
1

votes
1

answer
1.1k

Views

Conditional Thymeleaf fragments

I would like to create a list of up to three items using a template fragment. Three spaces for items will always be displayed regardless of whether or not there is an item, so it looks something like this. ; ; However, even though the th:if statement evaluates as false with an empty list, it still a...
user1834200
1

votes
1

answer
1.2k

Views

Thymeleaf #strings.trim() doesn't work

In short: I'm getting data from google places api and want to create entity in my db based on it. I have @Email annotation on a username field, so it can't contain white spaces. I was trying to use something like this: th:value='${#strings.trim(place.name) + '@mywebsite.com'}' But, it seems not...
Mykola Nagorskyi
0

votes
0

answer
3

Views

How to set input field for aggregated object in thymleaf using spring boot

I am trying to set the input fields for an aggregated object in thymleaf using Spring Boot. My Model is public class DearHelpUsers { private String id; private String username; private String email; private String password; private String cnfPassword; private String role; private String phoneNumber...
Md Anash Ansari
0

votes
0

answer
4

Views

Display many to many relationship in Spring Boot and Thymeleaf

I'm building a multichoices quiz application in Spring Boot, JPA and Thymeleaf. I have 3 tables in database: Question(ID, content), Choice(ID, content) and Quiz(question_id, choice_id, answer). The Quiz table created by the many to many relationship between Question and Choice tables. I have trouble...
user9610530
0

votes
0

answer
4

Views

Display unicode character

I use spring boot 2 with thymeleaf 3. I try to display an unicode character I get this error There was an unexpected error (type=Internal Server Error, status=500). Exception evaluating SpringEL expression: 'specialTry ? ☑ : ''' I tried th:utext='${sample.specialTry} ? '☑' : ''' only # is displa...
robert trudel
1

votes
1

answer
501

Views

Thymeleaf: Query String

How to create in Thymeleaf the url: /user/map?userId=1&mapId=2 In the thymeleaf model I have access to ${user.id} and ${map.id}. I have tried: th:href='@{'/user/map/update/?userId=' + ${user.id} + '&mapId=' + ${map.id}}' but it gives: The reference to entity 'mapId' must end with the ';' delimit...
Dachstein
1

votes
2

answer
685

Views

How to show error message in login page when user fail to login with Spring Boot?

Now i am doing project with Spring Boot. I wanted to show error message when I fail to login. When I did Maven project I did it easily with BindingResult. I followed several instruction to complete the task what I wanted to do. But I couldn't get any proper solution. I need a proper solution in simp...
Avijit Barua
1

votes
2

answer
2.4k

Views

escape apostrophe in thymeleaf variable

I'm trying to escape the apostrophes in the value of a variable that is passed as a string parameter using thymeleaf. My code looks like this: and when the html page is interpreted it looks like this: so the apostrophe from 'd'un' closes the parameter before it's meant to. Does anyone know how can i...
Laura Nechifor
1

votes
1

answer
3.9k

Views

Spring MVC Ajax Search Form Thymeleaf

So I'm trying to create a search form in the navbar of my site, and I'm using ajax to submit the form. I have other working search forms in my web app so I know how to do that. And I have the ajax submitting properly. I just don't know how to get the data from the form and use it in the controlle...
dochsner
1

votes
2

answer
2.3k

Views

thymeleaf - passing a Selection Variable Expression *{foo} to an Expression Utility Object

I have a spring backed form with a model object Foo that contains Bar now, I would like to do something like this: but the following parsing exeption is thrown: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProces...
mooor
1

votes
1

answer
1.4k

Views

How to generate edit modals for each element in the model?

I'm trying to use thymeleaf to generate edit and delete modals for each element in the model in my ModelAndView using th:each. The modals are indeed created and have unique ids based on the id field of the elements. The problem I have is none of the values from elements are parsed into the inputs to...
ChiefTwoPencils
1

votes
1

answer
175

Views

How to refer to a yet non-existent bean by using Spring @Configuration

I dislike XML configurations (those large and unreadable files) and I prefer using java code instead of them. I'm working with a simple web project based by Spring (Core, MVC) and Thymeleaf as a template engine. The snippet of code is laid out below. @EnableWebMvc @Configuration @ComponentScan({'co...
Andrew Tobilko
0

votes
0

answer
3

Views

Not able to generate Excel file correctly using Spring Boot and Apache POI

I have a very basic SpringBoot and Thymeleaf based application that is tied with Oracle DB. My application currently reads from a table and displays it on the page via a Controller and Thymeleaf UI template. I also have a link at the bottom of this table which says 'Export to Excel' which calls a me...
user2325154
1

votes
2

answer
282

Views

EAR not working in Weblogic 10.3.6

I'm using Eclipse and when I run the Spring MVC project under Pivotal tc (aka Tomcat), I have an image that is shown correctly (and I can reach its URL), but when I run under Weblogic 10.3.6 the EAR project (which load the Spring MVC project) the image is not showed, and when I try to load directly...
Accollativo
1

votes
1

answer
759

Views

Is it possible to use the success object from an AJAX call and pass it to thymeleaf to iterate over

Okay so I am new at Spring and ThymeLeaf and I am trying to learn how to use it so please be kind. So I have a REST service that is returning a list of objects. I have an ajax call that is making a query to my REST service and passing back the objects desired as a parsed JSON via Jackson. I want to...
Krysta
1

votes
1

answer
750

Views

spring thymeleaf remove quotes in validation message

I am using Spring Thymeleaf and I have form validation messages in an external messages.properties file. When I reference the message like this: th:attr='data-error=#{field.error.required.field}' as in the following input field declaration: When the validation message appears in the browser, it has...
broadbear
1

votes
1

answer
1.2k

Views

Using variables to build fragment name in th:include - ThymeLeaf + Spring Boot

I would like to use the fragment functionality without the th:fragment (just using id). And in my code, the target fragment to be included is dynamically built from an iterator. The problem is creating the proper expression for the th:include to be rendered correctly. I've tried Concatenation, Prepr...
aaaaarrrgghhh
1

votes
1

answer
1.3k

Views

How to escape double quotes in in thymeleaf?

I have the following code that I believe I need to escape in thymeleaf. th:required='' It throws the following error: org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: '' Any suggestions?
Albert
1

votes
1

answer
1k

Views

How to convert HTML table to List using Thymeleaf

I am creating an spring-boot MVC web application. When I get the contents from the controller I can display them correctly on the view. The content is an object with a List. The list is displayed on a table. ORDER TITLE HIDE EDIT Add Section When I change some values on the table I want to save the...
Michael Knight
1

votes
3

answer
777

Views

Unable to run Spring Boot WebMVC with Thymeleaf support

I have search a lot but I did not find answer to my question, So I am posting my question here. Please look and suggest me the solution where I am mistaken. I have created spring boot web mvc project with thymeleaf support using Spring Tool Suite(STS). When I run it give me 'Whitelabel Error Page' p...
Mandy
1

votes
1

answer
535

Views

How to iterate and print data inside <pre> with thymeleaf

At my spring controller I return a List inside the ModelAndView. This list has this data: { 'A', 'B', 'C' } At the HTML I want to print this data inside a tag, to get exacly this: A B C I dont want to create one tag for each item like this: How can I do this?
Beto Neto
1

votes
1

answer
683

Views

sec:authorize not being evaluated on spring-boot project

In my current spring-boot project, I have one view with this html code: ... ... but when I execute the application, apparently the tag sec:authorize isn't being evaluated, since both parts are being displayed. I configure thymeleaf in my application.properties file this way: # THYMELEAF (ThymeleafAu...
Kleber Mota
1

votes
1

answer
1.6k

Views

Add row to a table populated by thymeleaf

When I add a new row into a table populated by thymeleaf I found several issues. I cannot assign any stat.index The th:xxx tags are not represented when I add the rows by using javascript This is my HTML+thymeleaf code: This is my js code: function addBranch(table) { var tableRow = '' + '' + '' + ''...
Michael Knight
1

votes
1

answer
1.4k

Views

Thymeleaf - I can't pass two values from HTML to Controller using Link th:href

I am using Thymeleaf and Spring Boot. I have a link in my html using thymeleaf: SELECT When I only pass one value, it works but when I pass two values, it didn't. It has errors: Failed to convert value of type [java.lang.String] to required type [java.lang.Long]; nested exception is java.lang.Number...
Lester
1

votes
2

answer
802

Views

Conditional layout of multiple divs in Thymeleaf

I am struggling to format this div structure using th:each in Thymleaf. The desired html format is as follows Desired HTML Progress until now Any help would be highly appreciated. Thanks PS: HTML texts are removed for brevity
Abdullah Khan
1

votes
1

answer
624

Views

Thymeleaf would not resolve html entities

How do I get thymeleaf to resolve my html entities? I have the following: will simply produce an input element with 'Wayne’s World' instead of 'Wayne's world'. Any way to make thymeleaf resolve the html entities?
000
1

votes
2

answer
415

Views

empty constructor is not defined in Thymeleaf source jar

I am learning Thymeleaf from below url http://www.concretepage.com/spring-4/spring-4-security-thymeleaf-integration-custom-login-page-and-logout-example-with-csrf-token-using-javaconfig Instead on using Gradle, I have downloaded all required jars from Thymeleaf official page. Why does eclipse is thr...
Baljeet Singh
1

votes
1

answer
163

Views

Confused about ThymeleafConfig in Spring Boot

I added a ThymeleafConfig to my Spring Boot application so I could configure the template mode to HTML5. Prior to adding it, the Spring Boot application could find the home.html template. After adding it now I get a: org.thymeleaf.exceptions.TemplateInputException: Error resolving template 'home', t...
David Findlay
1

votes
1

answer
507

Views

Thymleaf switch statement in table

I want to set my tr class to bg-success when the status is equals 'EXECUTED'. Here is my code: ... It's obvious that I append two tr rows and don't close the first one, but in reality it's just one appended. One solution is to rewrite the ... in every case but it's a poor one. Is there any better so...
Rached Anis
1

votes
1

answer
199

Views

Using ampersand sign within client-side template and render it with thymeleaf

I use jsrender lib for client-side template generation but the whole website's output is processed by thymeleaf (spring mvc). The problem is that js template contains condtiion i.e. {{if (index && (index == 0 || ... but thymeleaf requires all the ampersands be escaped as &, but this causes jsrender...
nKognito
1

votes
1

answer
1.1k

Views

Thymeleaf : Getting value from a map while iterating through a list

I'm trying to get the value from a map while iterating through a list. searchResult contains a list of Book objects and each has a list of categories. categoryFacetCounts is a map that contains counts for each category value. The map has values for all the possible categories (I debugged and checked...
tharindu_DG
1

votes
2

answer
961

Views

Thymeleaf authentication object is either null or empty on an error page

After successful login authentication was obviously not null, but while still login forcing an error makes the authentication null. Spring Boot 1.3.1 Thymeleaf 2.1.4 Thymeleaf-Spring4 2.1.4 Thymeleaf-Extras-SpringSecurity4 error.html (custom error page that handles errors/exception) ......
aalmero
1

votes
1

answer
351

Views

Add icon to a (link) element / element in element

I need to create an element that renders to this HTML, so that the icon is part of the a's inner HTML: Deutschland My current approach is the following But that of course overrides the icon with the th:text. Adding the icon to the text doesn't seem to work either... How do I do that in thymeleaf?
bambam
1

votes
1

answer
68

Views

Sign & not support in Thymeleaf

I wrote this script in my html: It is not wokring, but if I remove & from '&embedded' link. It works. How can I use & in my thymeleaf?
Lay Leangsros
0

votes
0

answer
10

Views

thymeleaf, bind model properties to multiple form elements

I have a model property (region) than can be bound to more than one form elements as shown below: Select one.. Select one.. as shown, region property of the model can be bound to either country or state and i have a radio group for user to select one of the two. My question is on how determine the o...
Samuel
1

votes
1

answer
1.1k

Views

Html with thymeleaf list

I have code like this: Dapibus ac facilisis in Continue Info its displays like this: but I dont want static content inside my list so im adding this: Dapibus ac facilisis in Continue Info but then Im getting this: long story short, the buttons are missing, any idea guys how I could solve it?
filemonczyk
1

votes
1

answer
1.3k

Views

Multiple requestmapping value with path variables from thymeleaf

I have to send two data from thymeleaf to controller like this in a th:href: Delet‌​e The controller is: @RequestMapping('/deleteItem/{listId}/{itemId}') public String deleteItem(Model model, @PathVariable(value = 'listId') Integer listId, @PathVariable(value = 'itemId') int itemId) { ... return...
Utku Soytaş
1

votes
1

answer
1.7k

Views

Strange behavior by mixing vuejs 2.0 and Thymeleaf with SpringBoot

I've written some pages using Vuejs 2.0. In the static mode, all my components work and I could validate the design. So, I've tried to integrate the source of these pages into a Web Spring Boot project with Thymeleaf but some rendering is not done. A use case with the code below: Alsace-Champagne-Ar...
ChriX

View additional questions