相关疑难解决方法(0)

如何获得与平台相关的新行字符?

如何在Java中获得与平台相关的换行符?我不能"\n"到处使用.

java cross-platform newline eol

531
推荐指数
8
解决办法
42万
查看次数

Spring Data Rest控制器:@BasePathAwareController,@ RepositoryRestController,@ Controller和@RestController的行为和用法

我试图了解Spring Data Rest Controller的确切行为.

我做了一个简单的实现,测试4种注解控制器:@BasePathAwareController,@RepositoryRestController,@RestController,@Controller

控制器具有存储库中实体"作者"的映射.

这是控制器:

@BasePathAwareController
//@RepositoryRestController
//@RestController
//@Controller
public class MyController {

    @RequestMapping(value="authors/mycontroller/test")
    public void handleRequest(){
        System.out.println("handleRequest of class MyController");
    }

    @RequestMapping(value="/authors/mycontroller/testslash")
    public void handleSlashRequest(){
        System.out.println("handleSlashRequest of class MyController");
    }

    @RequestMapping(value="api/authors/mycontroller/test")
    public void handleApiRequest(){
        System.out.println("handleApiRequest of class MyController");
    }

    @RequestMapping(value="/api/authors/mycontroller/testslash")
    public void handleSlashApiRequest(){
        System.out.println("handleSlashApiRequest of class MyController");
    }

}
Run Code Online (Sandbox Code Playgroud)

我正在测试4种方法,因为我对要使用的正确映射有一些疑问.

对于每个实验,我使用具有相同映射的不同控制器,只需取消注释该实验所需的注释.

我用HTTP GET调用这两个URL:

http://localhost:8080/myApp/api/mycontroller/test
http://localhost:8080/myApp/api/mycontroller/testslash
Run Code Online (Sandbox Code Playgroud)

这是我获得的结果@BasePathAwareController:

http://localhost:8080/myApp/api/mycontroller/test
    White page, No errors, No print on console

http://localhost:8080/myApp/api/mycontroller/testslash
    White page, …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc spring-data-rest

12
推荐指数
1
解决办法
4116
查看次数