Intro to JavaWeb

📢 This article was translated by gemini-3-flash-preview

SpringBoot Getting Started Example

Goal: Build a web application using SpringBoot where a browser request to /hello returns the string “Hello Spring”.

First, create a SpringBoot project and select the web development dependencies.

Next, create a controller class. Create Controller/HelloController.java in the same directory as your *Application.java file.

1
2
3
4
5
6
7
8
9
@RestController
public class HelloController{
    @RequestMapping("/hello")
    public String hello(){
        String s = "Hello Spring";
        System.out.println(s);
        return s;
    }
}

Run the *Application.java class and visit http://localhost:8080/hello in your browser.

HTTP

HTTP (Hypertext Transfer Protocol) is based on TCP (connection-oriented, secure) and follows a request-response model (one request corresponds to one response).

HTTP is a stateless protocol, meaning it has no memory of past transactions. Each request-response pair is independent. This makes it fast, but it also means data cannot be shared between multiple requests by default.

For more details, see: https://blog.yexca.net/archives/64