Добрый день, учу сприн, как при старте приложение что бы дефолтом вызывался index.html?
то есть если дефолтный путь
localhost:8080/MakeYourDream - то на нем я и видел index.html
Все файлы html вот тут лежат - /WEB-INF/view/
Где я ошибся или что я не дописал?
web.xml
<servlet>
<servlet-name>servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/app-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
spring-servlet
<bean id="templateResolve" class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
<property name="prefix" value="/WEB-INF/view/"/>
<property name="suffix" value=".html"/>
<property name="templateMode" value="HTML5"/>
</bean>
Controller
@Controller
public class MainController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(Model model){
model.addAttribute("message", "Hello index");
return "index";
}
}
Стектрейс
14:17:35,048 WARN [org.springframework.web.servlet.PageNotFound] (default task-1) No mapping found for HTTP request with URI [/MakeYourDream/] in DispatcherServlet with name 'servlet'
14:17:44,292 WARN [org.springframework.web.servlet.PageNotFound] (default task-1) No mapping found for HTTP request with URI [/MakeYourDream/] in DispatcherServlet with name 'servlet'
14:18:09,112 WARN [org.springframework.web.servlet.PageNotFound] (default task-1) No mapping found for HTTP request with URI [/MakeYourDream/INDEX] in DispatcherServlet with name 'servlet'
14:18:35,091 WARN [org.springframework.web.servlet.PageNotFound] (default task-1) No mapping found for HTTP request with URI [/MakeYourDream/index] in DispatcherServlet with name 'servlet'