Skip to content

LearnAWS-io/Simple-Java-Spring-boot-web-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Java Spring boot web server

hello world in spring on the root path

Using curl to preview the response:

❯ curl localhost:8080/hello\?name=LearnAWS.io
Hello LearnAWS.io! It's 2024-06-19T22:18:38.787292626Z%   

How to run this?

Start the spring web server using mvn

mvn spring-boot:run

Code for GET routes

@GetMapping("/")
public ResponseEntity<String> welcome() {
  String body = """
      <h1>Welcome to Spring boot</h1>
      <p>Made by <a href='https://learnaws.io'>LearnAWS.io</a>
      """;
  return ResponseEntity.ok().header("Content-Type", "text/html").body(body);
}

@GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
  return String.format("Hello %s! It's %s", name, Instant.now());
}

About

A simple hello world web application written in Java spring boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages