[JAVA] A story packed with the basics of Spring Boot (solved)

Domo is Fugito.

This time is a memorandum of rudimentary errors. Specifically, "Using Spring Boot and Thymeleaf, "Hello World" at http: // localhost: 8080 I met when prototyping an MVC application to display It is a record of "Handling the whitelabel error page".

First, create a project

I made it according to the article of here. Start the server according to the article as it is, go to the localhost page ....

The error page is

I forgot to take a screenshot, but I immediately encountered an error page. If you take a closer look "This application has no explicit mapping for /error" And that. HM?

Search by error message for the time being

2020-04-16.png

Apparently it's an error that tends to get hooked. But "Try adding Thymeleaf to your dependencies" etc. Congratulations on what you're doing ... sweat Do I have to ask this question myself ...?

Oh? ??

With HelloController.java created by myself I found a difference by comparing it with the controller source listed in this article.

package com.example.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@RequestMapping("")
@Controller
public class PortalController {

   @RequestMapping("")
   public String index() {
   System.out.println("aaa");
   return "home";
   }
} 
package com.example.demo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


@Controller 
public class HelloController {
   @RequestMapping("/")
   public ModelAndView index(){
       ModelAndView model = new ModelAndView();
       model.setViewName("index"); 
       return model;
   }
}

** RequestMapping annotation before Controller annotation I can't attach it. ** **

Maybe this is ...?

Added Request Mapping with half confidence. Then ...

I got it

2020-04-16 (2).png I'm not sure, but it was displayed properly. Really do it. I will study again. Honestly around here today.

Recommended Posts

A story packed with the basics of Spring Boot (solved)
The story of raising Spring Boot 1.5 series to 2.1 series
Access the built-in h2db of spring boot with jdbcTemplate
The story of making a reverse proxy with ProxyServlet
The story of raising Spring Boot from 1.5 series to 2.1 series part2
[Spring Boot] The story that the bean of the class with ConfigurationProperties annotation was not found
The basics of the process of making a call with an Android app
The story of the first Rails app refactored with a self-made helper
Get a proxy instance of the component itself in Spring Boot
A story about hitting the League Of Legends API with JAVA
A story that struggled with the introduction of Web Apple Pay
See the behavior of entity update with Spring Boot + Spring Data JPA
A story that made me regret when a "NotReadablePropertyException" occurred during the development of the Spring Boot application.
Create a Spring Boot app development project with the cURL + tar command
The story of making a game launcher with automatic loading function [Java]
Create a website with Spring Boot + Gradle (jdk1.8.x)
Create a simple search app with Spring Boot
The story of tuning android apps with libGDX
Let's check the feel of Spring Boot + Swagger 2.0
A story packed with Java's standard input Scanner
Create a web api server with spring boot
Create a Spring Boot development environment with docker
Introducing the Spring Boot Actuator, a function that makes the operation of Spring Boot applications easier.
Organize the differences in behavior of @NotBlank, @NotEmpty, @NotNull with Spring Boot + Thymeleaf
Get the path defined in Controller class of Spring boot as a list
Resource handler settings when delivering SPA with the static resource function of Spring Boot
I tried to clone a web application full of bugs with Spring Boot
Download with Spring Boot
Specify the encoding of static resources in Spring Boot
A memorandum of addiction to Spring Boot2 x Doma2
05. I tried to stub the source of Spring Boot
[JUnit 5 compatible] Write a test using JUnit 5 with Spring boot 2.2, 2.3
I tried to reduce the capacity of Spring Boot
Implement a simple Rest API with Spring Security with Spring Boot 2.0
[JUnit 5] Write a validation test with Spring Boot! [Parameterization test]
A memorandum when creating a REST service with Spring Boot
Create Restapi with Spring Boot ((1) Until Run of App)
Create a simple demo site with Spring Security with Spring Boot 2.1
A review note of the Spring Framework Resource interface
How to boot by environment with Spring Boot of Maven
I wrote a test with Spring Boot + JUnit 5 now
Control the processing flow of Spring Batch with JavaConfig.
A record of studying the Spring Framework from scratch
The story of making dto, dao-like with java, sqlite
[Jackson] A story about converting the return value of BigDecimal type with a custom serializer.
Write a test by implementing the story of Mr. Nabeats in the world with ruby
Error handling when the maximum file size is exceeded when uploading a file with Spring Boot
A story that stumbled when deploying a web application created with Spring Boot to EC2
Generate barcode with Spring Boot
Hello World with Spring Boot
Story of making a task management application with swing, java
About the function of Spring Boot due to different versions
Change the injection target for each environment with Spring Boot 2
Docker monitoring-explaining the basics of basics-
Implement GraphQL with Spring Boot
The story of pushing a Docker container to GitHub Package Registry and Docker Hub with GitHub Actions
Understand the basics of docker
Hello World with Spring Boot!
The first WEB application with Spring Boot-Making a Pomodoro timer-
Check the operation of two roles with a chat application
Extract SQL to property file with jdbcTemplate of spring boot