spring-mvc

Error resolving template with Spring Boot using Thymeleaf packaged in a .jar

人走茶凉 提交于 2020-01-10 20:09:55
问题 I have a Spring Boot application using Thymeleaf as template resolver, which works fine when debugging from NetBeans, but gives me this error running its .jar: Error resolving template "/theme/property", template might not exist or might not be accessible by any of the configured Template Resolvers The app is set to auto-configurer with the annotation @SpringBootApplication, at an extension of SpringBootServletInitializer. I haven't set any contextPath into the properties file. I'm using

Spring URI Template Patterns with Regular Expressions

穿精又带淫゛_ 提交于 2020-01-10 19:43:14
问题 Hey someone know how can match this URI "http://localhost:8080/test/user/127.0.0.1:8002:8" with @RequestMapping. I try to write this code: @RequestMapping(value = "/user/{id}", method = RequestMethod.GET, headers = "Accept=application/xml") public void test(@PathVariable("id") String id) { System.out.println(id); return null; } but the problem is when i print the id the value is: 127.0.0 . Maybe something is wrong? 回答1: See the SpEL documentation: http://static.springsource.org/spring/docs/3

Should mapping value be declared in a constant or as an enum?

99封情书 提交于 2020-01-10 19:08:07
问题 I see this scattered throughout code base: @RequestMapping(value = "myValue") I would prefer to use something like this: @RequestMapping(value = Constants.myValue) It seems to break DRY using the actual String value within @RequestMapping instead of constant. But is this good code practice? Should I use an enum instead? I may need to use Constants.myValue elsewhere in the code base. 回答1: Should I use an enum instead? You can't. Annotation variables must be compile-time constants. Enums and

Is there another way to get a user's time zone from a HttpServletRequest object in Spring MVC? [duplicate]

淺唱寂寞╮ 提交于 2020-01-10 10:29:40
问题 This question already has answers here : How to detect the timezone of a client? (4 answers) Closed 2 years ago . I need to convert my server time to the user's time depending on their time zone. Is this the best way to figure out their timezone - by using the HttpServletRequest object? Locale clientLocale = request.getLocale(); Calendar calendar = Calendar.getInstance(clientLocale); TimeZone clientTimeZone = calendar.getTimeZone(); 回答1: Unfortunately you cannot get the user's timezone from

Is there another way to get a user's time zone from a HttpServletRequest object in Spring MVC? [duplicate]

橙三吉。 提交于 2020-01-10 10:29:23
问题 This question already has answers here : How to detect the timezone of a client? (4 answers) Closed 2 years ago . I need to convert my server time to the user's time depending on their time zone. Is this the best way to figure out their timezone - by using the HttpServletRequest object? Locale clientLocale = request.getLocale(); Calendar calendar = Calendar.getInstance(clientLocale); TimeZone clientTimeZone = calendar.getTimeZone(); 回答1: Unfortunately you cannot get the user's timezone from

How to configure spring boot security OAuth2 for ADFS?

Deadly 提交于 2020-01-10 08:37:20
问题 Has anyone successfully configured Spring Boot OAuth2 with ADFS as the identity provider? I followed this tutorial successfully for Facebook, https://spring.io/guides/tutorials/spring-boot-oauth2/, but ADFS doesn't appear to have a userInfoUri. I think ADFS returns the claims data in the token itself (JWT format?), but not sure how to make that work with Spring. Here is what I have so far in my properties file: security: oauth2: client: clientId: [client id setup with ADFS]

Thymeleaf th:text - Put a text without removing HTML structures

坚强是说给别人听的谎言 提交于 2020-01-10 07:26:57
问题 I'm new in thymeleaf and I try to create a template. My problem is this code: CODE <h1 th:text="${header.title}" > title <small th:text="${header.subtitle}" >Subtitle</small> </h1> I want to get this output: <h1> TITLE <small> SUBTITLE</small> </h1> But this is the real output: <h1> TITLE </h1> How can I do so it doesn't remove what is inside of "small"? 回答1: I faced the same problem. The answer is th:inline='text' This should solve your issue <h1 th:inline="text" > [[${header.title}]] <small

Thymeleaf th:text - Put a text without removing HTML structures

梦想的初衷 提交于 2020-01-10 07:26:07
问题 I'm new in thymeleaf and I try to create a template. My problem is this code: CODE <h1 th:text="${header.title}" > title <small th:text="${header.subtitle}" >Subtitle</small> </h1> I want to get this output: <h1> TITLE <small> SUBTITLE</small> </h1> But this is the real output: <h1> TITLE </h1> How can I do so it doesn't remove what is inside of "small"? 回答1: I faced the same problem. The answer is th:inline='text' This should solve your issue <h1 th:inline="text" > [[${header.title}]] <small

Spring Boot - where to place the jsp files

亡梦爱人 提交于 2020-01-10 04:59:05
问题 I am trying to develop a new Spring boot application using MVC as a first step to move my existing Spring MVC application to Spring boot. However, I am facing an issue with the mapping of jsp files. Could not resolve view with name 'hello' in servlet with name 'dispatcherServlet' I have ready many answers in SO, but none seem to solve my issue - I am not planning to use any template engines as I will have a lot of jsps to consider - might be a plan once spring boot is set up. I have a project

Spring Boot - where to place the jsp files

喜你入骨 提交于 2020-01-10 04:59:04
问题 I am trying to develop a new Spring boot application using MVC as a first step to move my existing Spring MVC application to Spring boot. However, I am facing an issue with the mapping of jsp files. Could not resolve view with name 'hello' in servlet with name 'dispatcherServlet' I have ready many answers in SO, but none seem to solve my issue - I am not planning to use any template engines as I will have a lot of jsps to consider - might be a plan once spring boot is set up. I have a project