Home > Back-end >  Spring boot access controller
Spring boot access controller

Time:09-22



Tried many times to not go to the controller has been showed 404 interface

CodePudding user response:

Replace @ Controller with @ RestController

CodePudding user response:

Scan tags to Example removed

CodePudding user response:

You access path??? 404 page screenshots?? Send up to look at it

CodePudding user response:

@ @ RestController instead of the Controller

CodePudding user response:

Add @ Controller with @ RestController or method above @ Responsebody annotation

CodePudding 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. Example

CodePudding user response:

When you launch the scan to you to define the Controller

CodePudding 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, sick

CodePudding 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 together

CodePudding 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:

  • Related