鍍金池/ 問(wèn)答/Java  HTML/ org.apache.jasper.JasperException

org.apache.jasper.JasperException

在java文件里面可以執(zhí)行,但是放到j(luò)sp頁(yè)面中就不行了

這個(gè)可以執(zhí)行

package com.mvc;

import com.mvc.bean.Goods;
import com.mvc.dao.GoodsDao;
import com.mvc.impl.GoodsDaoImpl;

import java.util.List;

public class selectGoodsTest {
    public static void main(String[] args) throws ClassNotFoundException {
        GoodsDao goodsDao = new GoodsDaoImpl();

        List<Goods> goodsTotal = goodsDao.getAllGoods();

        Goods goods = goodsDao.getGoodsById(1);

        System.out.println("根據(jù)ID獲取名字");
        System.out.println(goods.getGoodsName());
    }

}
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="com.mvc.bean.Goods"%>
<%@ page import="com.mvc.dao.GoodsDao"%>
<%@ page import="com.mvc.impl.GoodsDaoImpl"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <style type="text/css">
        div{
            float:left;
            margin: 10px;
        }
        div dd{
            margin:0px;
            font-size:10pt;
        }
        div dd.dd_name
        {
            color:blue;
        }
        div dd.dd_city
        {
            color:#000;
        }
    </style>
</head>

<body>

<!-- 商品循環(huán)開(kāi)始 -->
<%
    //圖書(shū)的實(shí)體類(lèi)創(chuàng)建一個(gè)對(duì)象
    Goods goods = new Goods();
    //圖書(shū)的業(yè)務(wù)邏輯層
    GoodsDao goodsDao = new GoodsDaoImpl();
    List<Goods> goodsTotal = goodsDao.getAllGoods();
    if (goodsTotal != null) {

    } else {
        System.out.println("空指針");
    }
%>

<h1>商品展示</h1>
<hr>

    <table width="750" height="60" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td>

                <div>
                    <dl>
                        <dt>


                        </dt>
                        <dd class="dd_name"><%=goodsTotal.get(0).getGoodsName() %></dd>
                    </dl>
                </div>
                <!-- 商品循環(huán)結(jié)束 -->

            </td>
        </tr>
    </table>

</body>
</html>

圖片描述
圖片描述

回答
編輯回答
殘淚

是否已經(jīng)導(dǎo)入mysql的jar包?

2018年1月15日 09:19