我可以在其他页面使用 Sql 标记数据源吗?
Can i use Sql tag dataSource other page?
我可以使用 Sql 标记 dataSource 其他具有应用程序或请求范围的页面吗?
示例:在 index.jsp 页面中我有连接:
<sql:setDataSource user="root" driver="com.mysql.jdbc.Driver" password="123" var="db" scope="application" url="jdbc:mysql://localhost/gallery"/>
我不会在我的其他页面中使用此连接
图库页面中的示例
<sql:setDataSource var="d" dataSource="${applicationScope.db}"/>
答案是是可以将日期源存储在范围变量中并在另一个页面中使用它但是是正确的做什么?
答案是 否 我的建议是完全忘记 <sql>
标记,并在 servlet 中进行所有数据库操作。使用 RequestDispatcher 将请求从 servlet 分派到 JSP。
The JSTL SQL tags for accessing databases listed in Table 7-7 are
designed for quick prototyping and simple applications. For production
applications, database operations are normally encapsulated in
JavaBeans components.
我可以使用 Sql 标记 dataSource 其他具有应用程序或请求范围的页面吗? 示例:在 index.jsp 页面中我有连接:
<sql:setDataSource user="root" driver="com.mysql.jdbc.Driver" password="123" var="db" scope="application" url="jdbc:mysql://localhost/gallery"/>
我不会在我的其他页面中使用此连接 图库页面中的示例
<sql:setDataSource var="d" dataSource="${applicationScope.db}"/>
答案是是可以将日期源存储在范围变量中并在另一个页面中使用它但是是正确的做什么?
答案是 否 我的建议是完全忘记 <sql>
标记,并在 servlet 中进行所有数据库操作。使用 RequestDispatcher 将请求从 servlet 分派到 JSP。
The JSTL SQL tags for accessing databases listed in Table 7-7 are designed for quick prototyping and simple applications. For production applications, database operations are normally encapsulated in JavaBeans components.