I create a project using Spring Initializer.
I added a mapping for /hello:
package com.propfinancing.www;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class PfWebApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(PfWebApplication.class, args);
}
@GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s!", name);
}
}
I created a war file and uploaded that to my tomcat server. When I go to the URL http://dev.propfinancing.com/www/hello
I get a 404 - Not Found page.
Any idea what went wrong?
CodePudding user response:
I think I figured it out.
Apparently, Spring 5 does not work with tomcat 10:
https://github.com/spring-projects/spring-boot/issues/22414
I am going to install Tomcat 9 on my server and see if that works.
CodePudding user response:
Try with this
@GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s!", name);
}
localhost:8080/hello?name=abc
http://dev.propfinancing.com/hello?name=abc
