文章目录

1. 响应状态码的含义
1.1 官方网站
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Status
- 信息响应 (100–199)
- 成功响应 (200–299)
- 重定向消息 (300–399)
- 客户端错误响应 (400–499)
- 服务端错误响应 (500–599)
1.2 常见返回码
- 200:成功响应。
- 302:重定向。如:注册成功后重定向到新页面
- 404:服务器找不到请求的资源。
- 500:服务器遇到了不知道如何处理的情况。
2. 服务端断点调试技巧
-
在想调试的地方打断点
-
两种方法进入debug调试
-
F8:让程序向下执行一行
-
F7:进入当前方法内部
-
F9:向下执行完毕,或到下一个断点
-
左下角断点管理
3. 客户端断点调试技巧
在“发布”上打断点
- F10:向下执行一行
- F11:进入方法内部
- F8:下一个断点或执行完毕
4. 设置日志级别,并将日志输出到不同的终端
https://logback.qos.ch/
如:启用info级,info及以上信息才会记录显示
4.1 test下创建LoggerTests
package com.nowcoder.community;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = CommunityApplication.class)
public class LoggerTests {
private static final Logger logger = LoggerFactory.getLogger(LoggerTests.class);
@Test
public void testLogger() {
System.out.println(logger.getName());
logger.debug("debug log");
logger.info(<