有2个问题请老师解答一下

有2个问题请老师解答一下

问题1:前台页面图片显示不出来

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>首页</title>
   <link rel="stylesheet" type="text/css" href="/style/common.css" />
   <link rel="stylesheet" type="text/css" href="/style/index.css" />
</head>
<body>
<div class="header">
   <div class="logo f1">
       <img src="/image/logo.png">
   </div>
   <div class="auth fr">
       <ul>
           <li><a href="/toLogin.do">登录</a></li>
           <li><a href="#">注册</a></li>
       </ul>
   </div>
</div>
<div class="content">
   <div class="banner">
       <img class="banner-img" src="/image/welcome.png" width="732px" height="372" alt="图片描述">
   </div>

   <div class="img-content">
       <ul>
           <c:forEach items="${pageInfo.list}" var="list">
               <li>
                   <img class="img-li-fix" src="${list.smallImg}">
                   <div class="info">
                       <h3 class="img_title">${list.name}</h3>
                       <p>
                               ${list.description}
                       </p>
                       <div class="btn">
                           <a href="/detail.do?id=${list.id}" class="edit">详情</a>
                       </div>
                   </div>
               </li>
           </c:forEach>
       </ul>
   </div>
   <div class="page-nav">
       <ul>
           <li><a href="">首页</a></li>
           <li><a href="">上一页</a></li>
           <li><a href=""><span class="first-page">1</span></a></li>
           <li><a href="">2</a></li>
           <li><a href="">3</a></li>
           <li><a href="">4</a></li>
           <li><a href="">5</a></li>
           <li>...</li>
           <li><a href="">98</a></li>
           <li><a href="">99</a></li>
           <li><a href="">下一页</a></li>
           <li><a href="">尾页</a></li>
       </ul>
   </div>
</div>

<div class="footer">
   <p><span>M-GALLARY</span><img draggable="false" class="moco-emoji" alt="©" src="https://www.imooc.com/static/moco/v1.0/images/face/36x36/a9.png" data-src="©" style="cursor: pointer;">2019 POWERED BY vincent.INC</p>
</div>
</body>
</html>


package com.vincent.canvas.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.vincent.canvas.biz.AccountBiz;
import com.vincent.canvas.biz.CanvasBiz;
import com.vincent.canvas.biz.CategoryBiz;
import com.vincent.canvas.biz.impl.AccountBizImpl;
import com.vincent.canvas.biz.impl.CanvasBizImpl;
import com.vincent.canvas.biz.impl.CategoryBizImpl;
import com.vincent.canvas.entity.Account;
import com.vincent.canvas.entity.Canvas;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


public class DefaultController {
   private AccountBiz accountBiz= new AccountBizImpl();
   private CategoryBiz categoryBiz=new CategoryBizImpl();
   private CanvasBiz canvasBiz=new CanvasBizImpl();

   //  /toLogin.do
   public void toLogin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       request.getRequestDispatcher("/WEB-INF/pages/admin/login.jsp").forward(request,response);
   }
   //  /login.do
   public void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       String name = request.getParameter("account");
       String password = request.getParameter("password");
       Account account = accountBiz.login(name,password);
       if(account==null)
           response.sendRedirect("toLogin.do");
       else{
           request.getSession().setAttribute("ACCOUNT",account);
           response.sendRedirect("/admin/Canvas/list.do");
       }
   }
   //  /quit.do
   public void quit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       request.getSession().setAttribute("ACCOUNT",null);
       response.sendRedirect("toLogin.do");
   }

   //     /index.do
   public void index(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
       //分页
       String pageNum = request.getParameter("pageNum");
       if(pageNum==null){
           pageNum="1";
       }
       PageHelper.startPage(Integer.parseInt(pageNum),6);
       List<Canvas> list = canvasBiz.getShow();
       PageInfo pageInfo = PageInfo.of(list);
       request.setAttribute("pageInfo",pageInfo);
       request.getRequestDispatcher("/WEB-INF/pages/index.jsp").forward(request,response);
   }

   //      /detail.do
   public void detail(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
       int id = Integer.parseInt(request.getParameter("id"));
       Canvas canvas = canvasBiz.get(id);
       request.setAttribute("canvas",canvas);
       request.getRequestDispatcher("/WEB-INF/pages/detail.jsp").forward(request,response);
   }
}

http://img1.sycdn.imooc.com//climg/5da9d40d09a2f37f03830874.jpg

http://img1.sycdn.imooc.com//climg/5da9d40d09ae9b5c13780173.jpg

http://img1.sycdn.imooc.com//climg/5da9d440091df34619190752.jpg

问题2:油画列表点击编辑修改保存之后,没有反应

package com.vincent.canvas.controller;

import com.vincent.canvas.biz.CanvasBiz;
import com.vincent.canvas.biz.CategoryBiz;
import com.vincent.canvas.biz.impl.CanvasBizImpl;
import com.vincent.canvas.biz.impl.CategoryBizImpl;
import com.vincent.canvas.entity.Canvas;
import com.vincent.canvas.entity.Category;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

public class CanvasController {
   private CanvasBiz canvasBiz = new CanvasBizImpl();
   private CategoryBiz categoryBiz=new CategoryBizImpl();
   // /admin/canvas/list.do
   public void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       List<Canvas> list=canvasBiz.getAll();
       request.setAttribute("list",list);
       request.getRequestDispatcher("/WEB-INF/pages/admin/canvas_list.jsp").forward(request,response);
   }
   //      /admin/canvas/toAdd.do  打开添加界面
   public void toAdd(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
       List<Category> list = categoryBiz.getRoot();
       request.setAttribute("list",list);
       request.getRequestDispatcher("/WEB-INF/pages/admin/canvas_add.jsp").forward(request,response);
   }

   //      /admin/canvas/add.do  添加完成提交
   public void add(HttpServletRequest request,HttpServletResponse response) throws IOException, FileUploadException {
       Canvas canvas=builder(request);
       canvasBiz.add(canvas);
       response.sendRedirect("list.do");

   }
   //    /admin/canvas/toUpdate.do
   public  void  toUpdate(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
       int id=Integer.parseInt(request.getParameter("id"));
       Canvas canvas=canvasBiz.get(id);
       request.setAttribute("canvas",canvas);
       List<Category> list= categoryBiz.getRoot();
       request.setAttribute("list",list);
       request.getRequestDispatcher("/WEB-INF/pages/admin/canvas_update.jsp").forward(request,response);
   }

   //    /admin/canvas/update.do
   public void update(HttpServletRequest request,HttpServletResponse response) throws IOException, FileUploadException {
       Canvas canvas=builder(request);
       canvasBiz.edit(canvas);
       response.sendRedirect("list.do");
   }

   //     /admin/Canvas/remove.do
   public void remove(HttpServletRequest request,HttpServletResponse response) throws IOException {
       int id=Integer.parseInt(request.getParameter("id"));
       canvasBiz.remove(id);
       response.sendRedirect("list.do");
   }

   private Canvas builder(HttpServletRequest request) throws FileUploadException, UnsupportedEncodingException {
       Canvas canvas = new Canvas();
       FileItemFactory factory = new DiskFileItemFactory();
       ServletFileUpload upload = new ServletFileUpload(factory);
       upload.setHeaderEncoding("UTF-8");
       List<FileItem> list = upload.parseRequest(request);
       for(FileItem item:list){
           //判断是表单项还是文件上传项
           if(item.isFormField()){
               //表单项
               if(item.getFieldName().equals("id")){
                   canvas.setId(Integer.parseInt(item.getString("UTF-8")));
               }
               if(item.getFieldName().equals("categoryId")){
                   canvas.setCategoryId(Integer.parseInt(item.getString("UTF-8")));
               }
               if(item.getFieldName().equals("name")){
                   canvas.setName(item.getString("UTF-8"));
               }
               if (item.getFieldName().equals("price")){
                   canvas.setPrice(Integer.parseInt(item.getString("UTF-8")));
               }
               if(item.getFieldName().equals("description")){
                   canvas.setDescription(item.getString("UTF-8"));
               }
               if(item.getFieldName().equals("smallImg")&&canvas.getSmallImg()==null){
                   canvas.setSmallImg(item.getString("UTF-8"));
               }else{
                   //文件上传项
                   if(item.getFieldName().equals("smallImg")){
                       if(item.getSize()<=100) continue;
                       String rootPath=request.getServletContext().getRealPath("/");
                       String path=item.getName();
                       String type=".jpg";
                       if(path.indexOf(".")!=-1){
                           type=path.substring(path.lastIndexOf("."));
                       }
                       path="/download/images/"+System.currentTimeMillis()+type;
                       try {
                           item.write(new File(rootPath+path));
                           canvas.setSmallImg(path);
                       } catch (Exception e) {
                           e.printStackTrace();
                       }
                   }
               }
           }
       }
       return canvas;
   }
}


package com.vincent.canvas.dao;
import com.vincent.canvas.entity.Canvas;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CanvasDao {
   //添加商品
   @Insert("insert into canvas (name,creator,categoryId,price,smallImg,createTime,description) values (#{name},#{creator},#{categoryId},#{price},#{smallImg},#{createTime},#{description})")
   @Options(useGeneratedKeys = true,keyProperty = "id")
   void insert(Canvas canvas);

   //编辑商品,createTime=#{createTime}
   @Update("update canvas set name=#{name},categoryId=#{categoryId},price=#{price},smallImg=#{smallImg},description=#{description} where id=#{id}")
   void update(Canvas canvas);

   //删除商品
   @Delete("delete from canvas where id=#{id}")
   void delete(int id);

   //查询单个商品
   @Select("select c.*,ca.name cname from canvas c inner join category ca on c.categoryId=ca.id where c.id=#{id}")
   @Results(id = "all",value = {
           @Result(column = "id",property = "id",id = true),
           @Result(column = "categoryId",property = "categoryId"),
           @Result(column = "name",property = "name"),
           @Result(column = "creator",property = "creator"),
           @Result(column = "price",property = "price"),
           @Result(column = "smallImg",property = "smallImg"),
           @Result(column = "createTime",property = "createTime"),
           @Result(column = "updateTime",property = "updateTime"),
           @Result(column = "description",property = "description"),
           @Result(column = "details",property = "details"),
           @Result(column = "cname",property = "category.name")
   })
   Canvas select(int id);

   //查询全部商品
   @Select("select c.*,ca.name cname from canvas c inner join category ca on c.categoryId=ca.id order by c.id desc")
   @ResultMap("all")
   List<Canvas> selectAll();


   //前台页面展示
   @Select("select c.*,ca.name cname from canvas c inner join category ca on c.categoryId=ca.id")
   @ResultMap("all")
   List<Canvas> selectShow();


}


package com.vincent.canvas.biz.impl;

import com.vincent.canvas.biz.CanvasBiz;
import com.vincent.canvas.dao.CanvasDao;
import com.vincent.canvas.entity.Canvas;
import com.vincent.canvas.global.DaoFactory;

import java.util.Date;
import java.util.List;

public class CanvasBizImpl implements CanvasBiz {
   private CanvasDao canvasDao = DaoFactory.getInstance().getDao(CanvasDao.class);
   public void add(Canvas canvas) {
       Date now = new Date();
       canvas.setCreateTime(now);
       canvas.setUpdateTime(now);
       canvasDao.insert(canvas);
   }

   public void edit(Canvas canvas) {
       canvasDao.update(canvas);
   }

   public void remove(int id) {
       canvasDao.delete(id);
   }

   public Canvas get(int id) {
       return canvasDao.select(id);
   }

   public List<Canvas> getAll() {
       return canvasDao.selectAll();
   }

   public List<Canvas> getShow() {
       return canvasDao.selectShow();
   }
}

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
   <head>
       <meta charset="UTF-8">
       <title>油画列表</title>
       <link rel="stylesheet" href="/css/index.css">
       <link rel="stylesheet" href="/css/bootstrap.min.css">
   </head>

   <body>
       <header>
           <div class="container">
                   <nav>
                       <a href="/admin/Category/list.do" >分类一</a>
                   </nav>
                   <nav>
                       <a href="/admin/Category/list.do" >分类</a>
                   </nav>
                   <nav>
                       <a href="/login.do">登录</a>
                       <a href="#" onclick="alert('功能暂未开放');">注册</a>
                   </nav>
           </div>
       </header>
       <section class="banner">
           <div class="container">
               <div>
                   <h1>油画</h1>
                   <p>油画列表</p>
               </div>
           </div>
       </section>
       <section class="main">
           <div class="container">
               <table class="table table-striped">
                   <thead>
                   <tr>
                       <th>名称</th>
                       <th>分类</th>
                       <th>价格</th>
                       <th>创建时间</th>
                       <th>最后修改时间</th>
                       <th>描述</th>
                       <th>编辑</th>
                       <th>删除</th>
                   </tr>
                   </thead>
                   <tbody>
                           <c:forEach items="${list}" var="canvas">
                           <tr>
                               <td>${canvas.name}</td>
                               <td>${canvas.category.name}</td>
                               <td>${canvas.price}</td>
                               <td>${canvas.createTime}</td>
                               <td>${canvas.updateTime}</td>
<%--                               <td><fmt:formatNumber type="currency" pattern="#,#00.00#" value="${canvas.price}"/></td>--%>
<%--                                <td><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${canvas.createTime}"/></td>--%>
<%--                                <td><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${canvas.updateTime}"/></td>--%>
                               <td>${canvas.description}</td>
                               <td><a href="/admin/Canvas/toUpdate.do?id=${canvas.id}">编辑</a></td>
                               <td><a href="/admin/Canvas/remove.do?id=${canvas.id}">删除</a>
                           </tr>
                           </c:forEach>
                   </tbody>
               </table>
           </div>
       </section>
       <section class="page">
           <div class="container">
               <div id="fatie">
                   <a href="/admin/Canvas/toAdd.do"><button>新建</button></a>
               </div>
           </div>
       </section>
       <footer>
           copy@vincent
       </footer>
   </body>
</html>


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
   <meta charset="UTF-8">
   <title>编辑</title>
   <link rel="stylesheet" href="/css/bootstrap.min.css">
   <link rel="stylesheet" href="/css/add.css">
</head>
<body>
<nav class="navbar navbar-default">
   <div class="container">
       <div class="navbar-header">
           <a class="navbar-brand" href="#">
               油画管理系统
           </a>
       </div>
   </div>
</nav>
<div class="container">
   <div class="jumbotron">
       <h1>Hello, admin!</h1>
       <p>请小心的编辑油画记录</p>
   </div>
   <div class="page-header">
       <h3><small>编辑</small></h3>
   </div>
   <form class="form-horizontal" action="/admin/Canvas/update.do" method="post" enctype="multipart/form-data">
       <input type="hidden" name="id" value="${canvas.id}">
       <div class="form-group">
           <label for="name" class="col-sm-2 control-label">名称 :</label>
           <div class="col-sm-8">
               <input name="name" class="form-control" id="name" value="${canvas.name}">
               <input type="hidden" name="id" class="form-control" id="id" value="001">
           </div>
       </div>
       <div class="form-group">
           <label for="categoryId" class="col-sm-2 control-label">分类 :</label>
           <select id="categoryId" name="categoryId" class="col-sm-2 form-control" style="width: auto">
               <c:forEach items="${list}" var="cat">
                   <option id="${cat.id}" value="${cat.id}">${cat.name}</option>
               </c:forEach>
           </select>
       </div>
       <div class="form-group">
           <label for="price" class="col-sm-2 control-label">价格 :</label>
           <div class="col-sm-8">
               <input name="price" type="number" class="form-control" id="price" value="${canvas.price}">
           </div>
       </div>
       <div class="form-group">
           <label for="smallImg" class="col-sm-2 control-label">图片 :</label>
           <div class="col-sm-8">
               <input id="smallImg" name="smallImg" class="file-loading"
                      type="file" multiple accept=".jpg,.jpeg,.png" data-min-file-count="1"
                      data-show-preview="true" value="${canvas.smallImg}">
           </div>
       </div>
       <div class="form-group">
           <label for="description" class="col-sm-2 control-label">描述 :</label>
           <div class="col-sm-8">
               <input name="description" type="text" class="form-control" id="description" value="${canvas.description}">
           </div>
       </div>


       <div class="form-group">
           <div class="col-sm-offset-2 col-sm-10">
               <button type="submit" class="btn btn-primary">保存</button>&nbsp;&nbsp;&nbsp;
           </div>
       </div>
   </form>
</div>
<footer class="text-center" >
   copy@vincent
</footer>
</body>
</html>


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

5回答
好帮手慕阿莹 2019-10-20 16:52:47

1、同学看一下数据库中的数据是否有变化呢?

2、同学再这里打印一下,看看是否进入到这里来了

http://img1.sycdn.imooc.com//climg/5dac1f8f0967649b04580179.jpg

3、在这里打印一下list,查看一下,修改后是否跳转到了这里,并且查出来的数据是否还是原来没有修改过的

http://img1.sycdn.imooc.com//climg/5dac200d09c3470c08990313.jpg

我们一步一步的排查一下哦。祝学习愉快

提问者 浮生Y一梦 2019-10-20 14:12:33

package com.vincent.canvas.biz;

import com.vincent.canvas.entity.Canvas;

import java.util.List;

public interface CanvasBiz {
   //添加商品
   void add(Canvas canvas);

   //编辑商品
   void edit(Canvas canvas);

   //删除商品
   void remove(int id);

   //获取单个商品
   Canvas get(int id);

   //获取全部商品
   List<Canvas> getAll();

   //前台展示
   List<Canvas> getShow();
}


package com.vincent.canvas.biz.impl;

import com.vincent.canvas.biz.CanvasBiz;
import com.vincent.canvas.dao.CanvasDao;
import com.vincent.canvas.entity.Canvas;
import com.vincent.canvas.global.DaoFactory;

import java.util.Date;
import java.util.List;

public class CanvasBizImpl implements CanvasBiz {
   private CanvasDao canvasDao = DaoFactory.getInstance().getDao(CanvasDao.class);
   public void add(Canvas canvas) {
       Date now = new Date();
       canvas.setCreateTime(now);
       canvas.setUpdateTime(now);
       canvasDao.insert(canvas);
   }

   public void edit(Canvas canvas) {
       canvasDao.update(canvas);
   }

   public void remove(int id) {
       canvasDao.delete(id);
   }

   public Canvas get(int id) {
       return canvasDao.select(id);
   }

   public List<Canvas> getAll() {
       return canvasDao.selectAll();
   }

   public List<Canvas> getShow() {
       return canvasDao.selectShow();
   }
}


package com.vincent.canvas.dao;
import com.vincent.canvas.entity.Canvas;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CanvasDao {
   //添加商品
   @Insert("insert into canvas (name,creator,categoryId,price,smallImg,createTime,description) values (#{name},#{creator},#{categoryId},#{price},#{smallImg},#{createTime},#{description})")
   @Options(useGeneratedKeys = true,keyProperty = "id")
   void insert(Canvas canvas);

   //编辑商品,createTime=#{createTime}
   @Update("update canvas set name=#{name},categoryId=#{categoryId},price=#{price},smallImg=#{smallImg},description=#{description} where id=#{id}")
   void update(Canvas canvas);

   //删除商品
   @Delete("delete from canvas where id=#{id}")
   void delete(int id);

   //查询单个商品
   @Select("select c.*,ca.name cname from canvas c inner join category ca on c.categoryId=ca.id where c.id=#{id}")
   @Results(id = "all",value = {
           @Result(column = "id",property = "id",id = true),
           @Result(column = "categoryId",property = "categoryId"),
           @Result(column = "name",property = "name"),
           @Result(column = "creator",property = "creator"),
           @Result(column = "price",property = "price"),
           @Result(column = "smallImg",property = "smallImg"),
           @Result(column = "createTime",property = "createTime"),
           @Result(column = "updateTime",property = "updateTime"),
           @Result(column = "description",property = "description"),
           @Result(column = "details",property = "details"),
           @Result(column = "cname",property = "category.name")
   })
   Canvas select(int id);

   //查询全部商品
   @Select("select c.*,ca.name cname from canvas c inner join category ca on c.categoryId=ca.id order by c.id desc")
   @ResultMap("all")
   List<Canvas> selectAll();


   //前台页面展示
   @Select("select c.*,ca.name cname from canvas c inner join category ca on c.categoryId=ca.id")
   @ResultMap("all")
   List<Canvas> selectShow();


}

好帮手慕阿莹 2019-10-20 10:55:14

关于编辑修改 

1、打印一下这个builder()返回的canvas,看看是否是你修改后的数据

http://img1.sycdn.imooc.com//climg/5dabcc3b094c053808430303.jpg

2、如果是,则检查一下 canvasBiz里的edit()方法是如何写的,有没有去调用更新的方法呢?

祝学习愉快

  • 提问者 浮生Y一梦 #1
    老师,这个地方打印的是地址
    2019-10-20 11:53:37
  • 好帮手慕阿莹 回复 提问者 浮生Y一梦 #2
    同学可以把你的Canvas 这个类添加一下toString方法哦。
    2019-10-20 11:56:18
  • 提问者 浮生Y一梦 回复 好帮手慕阿莹 #3
    老师,添加我toString方法后打印出的是我修改后的数据,对于老师说的调用更新的方法是什么意思
    2019-10-20 14:10:37
好帮手慕阿莹 2019-10-19 19:22:31

1、同学你好,同学数据库中的这个地址是通过添加页面添加进去的吗?还是手动复制进去的呢?

http://img1.sycdn.imooc.com//climg/5daaf0dd0979242213830167.jpg

添加油画的时候,同学可以打个断点,看看是否有进入这个如下部分把图片上传的代码呢?

http://img1.sycdn.imooc.com//climg/5daaf17409def65107170442.jpg

2、我们一般向数据库中都是存图片的地址呦。并不是直接把图片存到数据库中

3、请问同学点击修改保存后,页面是否有进行跳转呢?还是点击后,显示的还是原来的页面没有动呢?建议同学也可以打个断点跟一下,看看是否进入了controller中

如果我的回答解决了你的疑惑,请采纳!祝学习愉快!



  • 提问者 浮生Y一梦 #1
    我是通过/download/image/wudaojiaoshi.jpg写进数据库中的,就可以正常显示了
    2019-10-19 20:43:30
  • 提问者 浮生Y一梦 #2
    我点击修改保存后,页面有跳转,跳转到列表界面,但是数据并没有变化
    2019-10-19 20:46:00
好帮手慕阿莹 2019-10-19 13:43:52

1、同学可以看一下模块下对应的target文件夹或者out文件中下,找到对应的image文件夹下是否有对应的图片呢?

http://img1.sycdn.imooc.com//climg/5daa826a09a4b59d03020040.jpg


2、图片这里建议同学试一下,有没有进入到这个判断中呢?可以打印一下这个path,看看这个path的地址是什么?

http://img1.sycdn.imooc.com//climg/5daaa18909a8f07007080437.jpg

3、看一下编辑保存之后,idea中的控制台中是否有报错呢?包括一下几个地方:

http://img1.sycdn.imooc.com//climg/5daaa27a0952031f05830100.jpg

祝学习愉快!


  • 提问者 浮生Y一梦 #1
    老师我的target文件夹下没有image文件夹
    2019-10-19 19:10:15
  • 提问者 浮生Y一梦 #2
    老师,如何把图片添加进数据库中哈?
    2019-10-19 19:11:56
  • 提问者 浮生Y一梦 #3
    老师,编辑保存之后,idea中的控制台中没有报错
    2019-10-19 19:13:38
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
Java数据库开发与实战应用2018版
  • 参与学习           人
  • 提交作业       277    份
  • 解答问题       4297    个

Java数据库开发的必备技能,从流行的MySQL数据库开始,到Java原生的数据库管理接口JDBC的使用,再到常用的数据持久化框架MyBatis,让你向Java工程师的目标又迈进了一步!

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师