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:
- How to Solve Error: Required request body is missing
- [Solved] Sping controller Receives list entity parameter Error: nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256
- [Solved] Error resolving template “XXX”, template might not exist or might not be accessible by any of the
- [How to Solve] RestController cannot be recognized in spring boot
- Solve the problem of “resource interpreted as document but transferred with MIME type application / JSON” in IE browser
- Rust encountered error[E0554]: `#![feature]` may not be used on the stable release channel (switch nightly version)
- Block Wild Pointer crash: Thread 1:EXC_BAD_ACCESS(code=1,address=0x10)
- Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
- [Solved] NoSuchMethodError: org.springframework.boot.web.servlet.error.ErrorController.getErrorPath
- Flask Accessing an interface that returns a dictionary error: The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.