@artshelom

Как решить данную проблему при запуске Spring проекта??

Привет, делаю проект с данного сайта "spring-projects.ru/guides/serving-web-content", делаю все как написано, но при запуске выдает ошибку "[nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet dispatcherServlet threw exception"
Не пойму в чем проблема?
Вот код:
package hello;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class GreetingController {

    @RequestMapping("/greeting")
    public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
        System.out.println("Тут");
        model.addAttribute("name", name);
        return "greeting.html";
    }

}

package hello;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan
@EnableAutoConfiguration
public class Application {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

}

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <title>Getting Started: Serving Web Content</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'Hello, ' + ${name} + '!'" ></p>
</body>
</html>
  • Вопрос задан
  • 7621 просмотр
Решения вопроса 1
DarkRaven
@DarkRaven
разработка программного обеспечения
В обшем-то, вот ваша ошибка:
javax.servlet.ServletException: Circular view path [greeting.html]: would dispatch back to the current handler URL [/greeting.html] again. Check your ViewResolver setup!


Похоже, у вас есть роут /greeting.html и шаблон.
Попробуйте заменить
return "greeting.html"; на
return "greeting";
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы