```java import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.Map; @RestController @RequestMapping("/student") // 定义类请求路径 public class StudentController { @GetMapping("/info") // 定义方法请求路径 public Map<String, String> getStudentInfo() { Map<String, String> studentInfo = new HashMap<>(); studentInfo.put("studentname", "张三"); // 替换为自己的姓名 studentInfo.put("classname", "软件工程1班"); // 替换为自己的班级 studentInfo.put("studentno", "20210001"); // 替换为自己的学号 return studentInfo; } } ``` 需要注意的逻辑点: 1. 路径映射:确保 `@RequestMapping` 和 `@GetMapping` 的路径正确无误,避免与其他控制器的路径冲突。 2. 数据返回类型:使用 `Map<String, String>` 返回数据,确保数据格式符合需求。 3. 异常处理:考虑在实际项目中添加异常处理机制,确保在数据获取失败时能够返回友好的错误信息。 [2024-12-05 09:57:55 | AI写代码神器 | 266点数解答]