JSTL-java ee5 tutorial

JSTL includes a wide variety of tags that fit into discrete functional areas. To reflect this, as well as to give each area its own namespace, JSTL is exposed as multiple tag libraries. The URIs for the libraries are as follows:

    • Core: http://java.sun.com/jsp/jstl/core
    • XML: http://java.sun.com/jsp/jstl/xml
    • Internationalization: http://java.sun.com/jsp/jstl/fmt
    • SQL: http://java.sun.com/jsp/jstl/sql
    • Functions: http://java.sun.com/jsp/jstl/functions

the following table summarizes these functional areas along with the prefixes.

JSTL Tags 
Area
Subfunction
Prefix
Core
Variable support
c
Flow control
URL management
Miscellaneous
XML
Core
x
Flow control
Transformation
I18n
Locale
fmt
Message formatting
Number and date formatting
Database
SQL
sql
Functions
Collection length
fn
String manipulation

Thus, the tutorial references the JSTL core tags in JSP pages by using the following taglib directive:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" 
    prefix="c" %>

In addition to declaring the tag libraries, tutorial examples access the JSTL API and implementation. In the Application Server, the JSTL TLDs and libraries are distributed in the archive <J2EE_HOME>/lib/appserv-jstl.jar. This library is automatically loaded into the classpath of all web applications running on the Application Server, so you don't need to add it to your web application.

 
sql查询语句可以写为:
< sql:query  var ="books"  sql ="select * from web_bookstore_books where bookId='203'" ></ sql:query >

带参数:
< sql:query  var ="books"  dataSource ="jdbc/BookDB" >
        select * from web_bookstore_books where bookId=? 
< sql:param  value ="${bid}" />
</ sql:query >
还有:
< sql:query  var ="books"  sql ="select * from web_bookstore_books where bookId = ?"   >
       
< sql:param  value ="${bookId}"   />
</ sql:query >

数据库更新:
< sql:update  var ="books"  sql ="update web_bookstore_books set inventory = inventory - ? where bookId = ?"   >
       
< sql:param  value ="${item.quantity}"   />
       
< sql:param  value ="${bookId}"   />
</ sql:update >


注意配置文件:
< resource-ref >
        
< res-ref-name > jdbc/BookDB </ res-ref-name >
        
< res-type > javax.sql.DataSource </ res-type >
        
< res-auth > Container </ res-auth >
        
< res-sharing-scope > Shareable </ res-sharing-scope >
</ resource-ref >
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值