四.进行简单测试

1.写controller层

package com.why.controller;

import com.why.bean.Books;
import com.why.service.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @program: SSM
 * @description:
 * @author: @why
 * @create: 2020-09-03 13:56
 **/
@Controller
public class ControllerTest {
    @Autowired
  private   Service service;

    @GetMapping("/show")
    public String  showBookData(Model model){

        List<Books> bookMsg = service.getBookMsg();
        model.addAttribute("bookmsg",bookMsg);
        return "bookMsg";
    }
}

2.写jsp  

使用index页面来进行跳转

 

简单遍历一下

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: yasuo
  Date: 2020/9/3
  Time: 14:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<c:forEach items="${bookmsg}" var="book">
   <table>
       <tr>
           <td>${book.bookID}</td>
           <td>${book.bookName}</td>
           <td>${book.detail}</td>
           <td>${book.bookCounts}</td>
       </tr>
   </table>
</c:forEach>
</body>
</html>

中间爆了个异常,Public Key Retrieval is not allowed,百度了一下,直接在url上加上

 allowPublicKeyRetrieval=true就ok了

测试完毕。

 

开始去码云上找项目看项目做项目

 

posted @ 2020-09-03 14:24  why666  阅读(118)  评论(0编辑  收藏  举报