org.apache.jasper.JasperException

在java文件里面可以执行,但是放到jsp页面中就不行了

这个可以执行

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("根据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>

<!-- 商品循环开始 -->

<%

//图书的实体类创建一个对象

Goods goods = new Goods();

//图书的业务逻辑层

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>

<!-- 商品循环结束 -->

</td>

</tr>

</table>

</body>

</html>

图片描述
图片描述

回答:

是否已经导入mysql的jar包?

以上是 org.apache.jasper.JasperException 的全部内容, 来源链接: utcz.com/p/175601.html

回到顶部