Błąd rozwiązywania szablonu "indeks", szablon może nie istnieć lub może nie być dostępny przez którąkolwiek z skonfigurowanych funkcji rozwiązywania szablonów
To pytanie zostało już zadane, ale nie rozwiązałem mojego problemu i dostałem jakąś dziwną funkcjonalność.
Jeśli umieszczę swój indeks.plik html w katalogu statycznym tak:W przeglądarce pojawia się następujący błąd:
I w mojej konsoli:
[THYMELEAF][http-nio-8080-exec-3] Exception processing template "login":
Exception parsing document: template="login", line 6 - column 3
2015-08-11 16:09:07.922 ERROR 5756 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].
[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet]
in context with path [] threw exception [Request processing failed; nested
exception is org.thymeleaf.exceptions.TemplateInputException: Exception
parsing document: template="login", line 6 - column 3] with root cause
org.xml.sax.SAXParseException: The element type "meta" must be terminated by
the matching end-tag "</meta>".
Jednakże, jeśli przesunę mój indeks.plik html do katalogu templates dostaję następujący błąd w moim przeglądarka:
Dodałem mój widok:
@Controller
@EnableWebMvc
public class WebController extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/index").setViewName("index");
registry.addViewController("/results").setViewName("results");
registry.addViewController("/login").setViewName("login");
registry.addViewController("/form").setViewName("form");
}
@RequestMapping(value="/", method = RequestMethod.GET)
public String getHomePage(){
return "index";
}
@RequestMapping(value="/form", method=RequestMethod.GET)
public String showForm(Person person) {
return "form";
}
@RequestMapping(value="/form", method=RequestMethod.POST)
public String checkPersonInfo(@Valid Person person, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return "form";
}
return "redirect:/results";
}
@Bean
public ViewResolver getViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("templates/");
//resolver.setSuffix(".html");
return resolver;
}
@Override
public void configureDefaultServletHandling(
DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
WebSecurityConfig.java
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/index").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
}
}
Indeks.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<meta>
<meta> charset="UTF-8">
<title></title>
</head>
<body>
<h1>Welcome</h1>
<a href="../../login.html"><span>Click here to move to the next page</span></a>
</body>
</html>
W tym momencie Nie wiem, co się dzieje. Czy ktoś może mi coś doradzić?
------aktualizacja--------
Przegapiłem literówkę w indeksie.html ale i tak dostaję te same błędy
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta> charset="UTF-8">
<title></title>
</head>
<body>
<h1>Welcome</h1>
<a href="../../login.html"><span>Click here to move to the next page</span></a>
</body>
</html>
10 answers
W konsoli jest napisane, że jest to konflikt z logowaniem. Myślę, że należy zadeklarować również w indeksie.html tymeleaf. Coś w stylu:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>k</title>
</head>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-08-11 16:03:41
index.html
powinien być w środku templates
, Jak wiem. Więc twoja druga próba wygląda poprawnie.
Ale, jak mówi komunikat o błędzie, index.html
wygląda na jakieś błędy. Np. w trzeciej linii znacznik meta
powinien być znacznikiem head
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-08-11 14:42:49
Sprawdź nazwę
Szablony
Folder. powinny to być szablony, a nie szablony (bez s).
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-01-19 09:21:13
Można to rozwiązać kopiując poniższy kod w aplikacji.właściwości
spring.thymeleaf.enabled=false
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-01-03 19:28:11
Jeśli napotkasz ten problem i wszystko wygląda dobrze, spróbuj unieważnić pamięć podręczną / uruchom ponownie z IDE. To rozwiąże problem w większości przypadków.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-05-01 07:14:55
To czyni mnie sukcesem!
prefix: classpath:/templates/
Sprawdź swoją aplikację.yml
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-03-04 07:11:55
Ten błąd prawdopodobnie występuje przez większość czasu z powodu braku znacznika zamykającego. ponadto możesz skorzystać z następującej zależności, aby rozwiązać ten problem przy jednoczesnym wspieraniu starszego formatu HTML.
Ponieważ twój kod charset = "UTF-8" > tutaj nie ma zamknięcia dla meta tagu.
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-03-31 19:02:32
Dla mnie problemem była wrażliwość na wielkość liter. Używałem ~{fragments/Base}
zamiast ~{fragments/base}
(nazwa pliku to base.html
)
Moim środowiskiem programistycznym był windows, ale serwerem hostującym aplikację był Linux, więc nie zauważyłem tego problemu podczas programowania, ponieważ ścieżki systemu windows nie uwzględniają wielkości liter.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-08-09 06:03:13
Może to być spowodowane pewnymi wyjątkami, takimi jak (Parsing NUMERIC to String or vise versa).
Proszę sprawdzić wartości komórek albo są null lub obsłuż wyjątek i zobacz.
Best, Shahid
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-09-12 21:05:30
Jestem nowy w spring
Idź do --- > application.properties
Dodaj te :
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-09-03 13:10:48