This application has no explicit mapping for /error, so you are seeing this as a fallback

Build spring boot backend service, enter url, can’t access, prompt.

This application has no explicit mapping for /error, so you are seeing this as a fallback

Code:

@Controller
@SpringBootApplication
@RequestMapping("/webapp")
public class WebappApplication {

	@RequestMapping("/")
	String index() {
		System.out.println("login redirectx。。。");
		return "login";
	}

However, when you observe the output of the background, it shows that you have entered the method corresponding to the @ requestmapping path. Why does the browser not return the expected information (string “login”) but prompt 404 instead

After a period of trial and exploration, the solution is found

Change @ controller to @ restcontroller

@The controller treats the returned information as a URL

@Restcontroller returns information directly as content

The problem is solved and the information is returned successfully

Similar Posts: