在用jbuilder2005创建的工程里面创建代码如下:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<%@ page contentType="text/html; charset=gb2312" language="java" %>
<html>
<head>
<title>JSTL:的使用</title>
</head>
<body bgcolor="#FFFFFF">
创建普通的数据源:<br>
<sql:setDataSource
var="example1"
driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=zhaodong"
user="wo"
password="123"
/>
创建普通的数据源,把用户名和密码写在url中:<br>
<sql:setDataSource
var="example2"
driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=zhaodong;user=wo;password=123"
/>
从jndi名称空间中获得一个数据源。<br>
<sql:setDataSource
var="example3"
dataSource="jdbc/bn"
/>
<hr>
使用第一个数据源:<hr>
<sql:query var="query1" dataSource="${example1}">
SELECT * FROM usern
</sql:query>
<table border="1">
<c:forEach var="row" items="${query1.rows}">
<tr>
<td>Name: <c:out value="${row.username}"/></td>
<td>Value: <c:out value="${row.password}"/></td>
</tr>
</c:forEach>
</table>
使用第二个数据源:<hr>
<sql:query var="query2" dataSource="${example2}">
SELECT * FROM usern
</sql:query>
<table border="1">
<c:forEach var="row" items="${query2.rows}">
<tr>
<td>Name: <c:out value="${row.username}"/></td>
<td>Value: <c:out value="${row.password}"/></td>
</tr>
</c:forEach>
</table>使用第三个数据源:<hr>
<sql:query var="query3" dataSource="${example3}">
SELECT * FROM usern
</sql:query>
<table border="1">
<c:forEach var="row" items="${query3.rows}">
<tr>
<td>Name: <c:out value="${row.username}"/></td>
<td>Value: <c:out value="${row.password}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html>运行时出现提示:org.apache.jasper.JasperException: /jsp2.jsp(31,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
在tomcat下不在工程中,单独运行文件确能正常显示。
是哪个地方配置有毛病吗???
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<%@ page contentType="text/html; charset=gb2312" language="java" %>
<html>
<head>
<title>JSTL:的使用</title>
</head>
<body bgcolor="#FFFFFF">
创建普通的数据源:<br>
<sql:setDataSource
var="example1"
driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=zhaodong"
user="wo"
password="123"
/>
创建普通的数据源,把用户名和密码写在url中:<br>
<sql:setDataSource
var="example2"
driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=zhaodong;user=wo;password=123"
/>
从jndi名称空间中获得一个数据源。<br>
<sql:setDataSource
var="example3"
dataSource="jdbc/bn"
/>
<hr>
使用第一个数据源:<hr>
<sql:query var="query1" dataSource="${example1}">
SELECT * FROM usern
</sql:query>
<table border="1">
<c:forEach var="row" items="${query1.rows}">
<tr>
<td>Name: <c:out value="${row.username}"/></td>
<td>Value: <c:out value="${row.password}"/></td>
</tr>
</c:forEach>
</table>
使用第二个数据源:<hr>
<sql:query var="query2" dataSource="${example2}">
SELECT * FROM usern
</sql:query>
<table border="1">
<c:forEach var="row" items="${query2.rows}">
<tr>
<td>Name: <c:out value="${row.username}"/></td>
<td>Value: <c:out value="${row.password}"/></td>
</tr>
</c:forEach>
</table>使用第三个数据源:<hr>
<sql:query var="query3" dataSource="${example3}">
SELECT * FROM usern
</sql:query>
<table border="1">
<c:forEach var="row" items="${query3.rows}">
<tr>
<td>Name: <c:out value="${row.username}"/></td>
<td>Value: <c:out value="${row.password}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html>运行时出现提示:org.apache.jasper.JasperException: /jsp2.jsp(31,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
在tomcat下不在工程中,单独运行文件确能正常显示。
是哪个地方配置有毛病吗???
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@page contentType="text/html;charset=gb2312" language="java"%>
<hr/>
<c:out value="page is this import"></c:out>
userName=
<c:out value="${param.userName}"></c:out>
<hr/>
出现异常提示:org.apache.jasper.JasperException: /beimport.jsp(5,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions而把这段代码复制到TOMCAT下单独运行确能够正常输出userName=
问题出在${param.userName}这句上是不是工程中缺少配置?
JSTL什么版本?dataSource属性不支持EL表达式