SpringBoot-Halo study

在content/model/MainController中,Halo 为了实现跳转到登录页,采用了response.sendRedirect(adminIndexRedirectUri)来进行页面重定向,其中adminIndexRedirectUri的值为“ /admin/index.html”,是管理主界面。

在未登录状态时,AdminAutenticationFilter用来拦截除login状态的URL请求,具体请求见截图。

在最下方的if判断中,我做了改动,将原本要抛出exception变为了一个重定向到index.html. 在访问127.0.0.1:8090/api/admin/statistics时会跳转到登录页面,而用其它的URL,比如http://127.0.0.1:8090/api/admin/migrations/halo,则会出现405,Request method 'GET' not supported,原因是controller并没有实现对get方法的控制,所以总结:在有对应的controller方法的情况下,filter才会起作用,没有controller对应方法时,直接返回Request method 'GET' not supported。
Controller:
每一个controller都返回一个数据Object,此Object将会与其它信息组合为json文件作为对请求的响应。
接下来学习:swaggerConfigeration
未登录时,程序抛出exception后系统怎样处理?调用对应的handler进行处理
index.html分层的机制?路由
API的应用:前端应用API发送数据请求
从controller的返回值到后端的响应请求的过程
前端发出的URL->对应的filter-》对应的handler处理-〉对应的controller-》对应的service-〉controller生成数据DTO-》返回标准的response
接下来学习:
controller返回值到response
缓存机制
请求响应
@RestController注解,代表返回的是json格式的数据,这个注解是Spring4之后新加的注解,原来返回json格式的数据需要@ResponseBody配合@Controller一起使用;

浙公网安备 33010602011771号