今日总结

发布时间 2023-10-22 19:00:48作者: 冰稀饭Aurora

今天主要花时间学习了SpringMVC相关知识,并创建了一个练习项目,实践操作Springmvc

package com.aurora.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloController {
    //handler -> springmvc/hello return "hello spring mvc!"
    @RequestMapping("springmvc/hello") //对外访问的地址,到handlerMapping注册的注解
    @ResponseBody //直接返回字符串给前端,不要找视图解析器
    public String hello(){

        System.out.println("HelloController.hello");
        //返回给前端
        return "hello springmvc";
    }
}