• 大小: 37.78MB
    文件类型: .zip
    金币: 2
    下载: 0 次
    发布日期: 2024-01-29
  • 语言: 其他
  • 标签: 人工智能  

资源简介

springMVC学习,哈哈哈哈

资源截图

代码片段和文件信息

package cn.itcast.controller;

import cn.itcast.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.Map;

/**
 * 常用的注解
 */
@Controller
@RequestMapping(“/anno“)
@SessionAttributes(value = {“msg“})//把msg=美美存入到session域对中
public class AnnoController {

    @RequestMapping(“/testRequestParam“)
    public String testRequestParam(@RequestParam(name=“name“) String username){
        System.out.println(“执行了“);
        System.out.println(username);
        return “success“;
    }

    /**
     * 获取到请求体的内容
     * @param body
     * @return
     */
    @RequestMapping(“/testRequestBody“)
    public String testRequestBody(@RequestBody String body){
        System.out.println(“执行了“);
        System.out.println(body);
        return “success“;
    }

    /**
     * PathVariable注解
     * @param id
     * @return
     */
    @RequestMapping(“/testPathVariable/{sid}“)
    public String testPathVariable(@PathVariable(name = “sid“) String id){
        System.out.println(“执行了“);
        System.out.println(id);
        return “success“;
    }

    /**
     * 获取请求头的值
     * @param header
     * @return
     */
    @RequestMapping(“/testRequestHeader“)
    public String testRequestHeader(@RequestHeader(value = “Accept“) String header){
        System.out.println(“执行了“);
        System.out.println(header);
        return “success“;
    }

    /**
     *获取cookie的值
     * @param cookieValue
     * @return
     */
    @RequestMapping(“/testCookieValue“)
    public String testCookieValue(@CookieValue(value=“JSESSIONID“) String cookieValue){
        System.out.println(“执行了“);
        System.out.println(cookieValue);
        return “success“;
    }

    /**
     * ModelAttribute注解
     * @return
     */
    @RequestMapping(“/testModelAttribute“)
    public String testModelAttribute(@ModelAttribute(“abc“) User user){
        System.out.println(“testModelAttribute执行了“);
        System.out.println(user);
        return “success“;
    }

    /**
     * 该方法会先执行
     */

    @ModelAttribute
    public void showUser(String uname Map map){
        System.out.println(“showUser执行了“);
        //通过用户查询数据库(模拟)
        User user=new User();
        user.setUname(uname);
        user.setAge(20);
        user.setDate(new Date());
        map.put(“abc“user);
    }

//    @ModelAttribute
//    public User showUser(String uname){
//        System.out.println(“showUser执行了“);
//        //通过用户查询数据库(模拟)
//        User user=new User();
//        user.setUname(uname);
//        user.setAge(20);
//        user.setDate(new Date());
//        return user;
//    }

    /**
     * SessionAttributes的注解
     * @return
     */
    @RequestMapping(“/testSessionAttributes“)
    public String testSessionAttributes(Model model){
        System.out.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-04-14 17:58  SpringMVC\
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\
     文件        1295  2019-03-26 11:39  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\anno.jsp
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\meta-INF\
     文件          83  2019-03-26 11:55  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\meta-INF\MANIFEST.MF
     文件         383  2019-03-24 20:22  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\index.jsp
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\itcast\
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\itcast\utils\
     文件        1232  2019-03-25 13:50  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\itcast\utils\StringToDateConverter.class
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\itcast\controller\
     文件         842  2019-03-24 19:52  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\itcast\controller\HelloController.class
     文件        3593  2019-03-26 11:55  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\itcast\controller\AnnoController.class
     文件        2358  2019-03-25 14:16  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\itcast\controller\ParamController.class
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\itcast\domain\
     文件        1423  2019-03-25 18:19  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\itcast\domain\User.class
     文件        2389  2019-03-25 11:32  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\cn\itcast\domain\Account.class
     文件        1639  2019-03-25 13:52  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\classes\springmvc.xml
     目录           0  2019-04-14 17:58  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\lib\
     文件       61829  2019-03-06 20:33  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\lib\commons-logging-1.2.jar
     文件      915615  2019-03-04 11:55  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\lib\spring-webmvc-4.3.7.RELEASE.jar
     文件      380004  2019-03-03 21:37  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\lib\spring-aop-4.3.7.RELEASE.jar
     文件      263286  2019-03-03 21:37  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\lib\spring-expression-4.3.7.RELEASE.jar
     文件     1139269  2019-03-03 21:37  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\lib\spring-context-4.3.7.RELEASE.jar
     文件      817936  2019-03-04 11:55  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\lib\spring-web-4.3.7.RELEASE.jar
     文件      762747  2019-03-03 21:37  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\lib\spring-beans-4.3.7.RELEASE.jar
     文件     1118609  2019-03-03 21:37  SpringMVC\springmvc_day01_01_start\target\springmvc_day01_01_start\WEB-INF\lib\spring-core-4.3.7.RELEASE.jar
............此处省略312个文件信息

评论

共有 条评论