Tried many times to not go to the controller has been showed 404 interface
CodePudding user response:
Replace @ Controller with @ RestControllerCodePudding user response:
Scan tags to Example removedCodePudding user response:
You access path??? 404 page screenshots?? Send up to look at itCodePudding user response:
@ @ RestController instead of the ControllerCodePudding user response:
Add @ Controller with @ RestController or method above @ Responsebody annotationCodePudding user response:
Upstairs to, either @ controller to @ RestController or add a @ ResponseBody annotations, otherwise will call the default view parser to find the corresponding page, obviously you this page doesn't exist, so will return 404,Is the role of @ responseBody annotation controller () method returns the object through the appropriate convertor is converted to the specified format, write to the response the body area of the object, rather than call view parser, is often used to return the JSON data or XML
CodePudding user response:
@ SpringBootApplication followed by (scanBasePackages="com")CodePudding user response:
Put start classes in the outer package com. ExampleCodePudding user response:
When you launch the scan to you to define the ControllerCodePudding user response:
Upstairs, a group of zz, TMD Lao tze is the outer package, TMD seems to be the startup console does not reflect the mapper... What lousy seven or eight bad didn't scan, sickCodePudding user response:
Springboot start class can only identify the class under the directory at the same level or sub package, you put the Example class in Demo2Application class can work togetherCodePudding user response:
SpingBoot contextPath configuration by default is "/", i.e. access path don't have to add the project name, has just been the pit, leave a footprint here,CodePudding user response:
Put your bag are Demo2Application position, at the same level or scanBasePackages="com"CodePudding user response:
Do not add RestController, return the result after view the parser.CodePudding user response: