【JavaWeb】JSTLラベルライブラリ
4371 ワード
JSTLラベルライブラリ
JSTL標準ラベルライブラリ;
JSTLはJSPの開発を簡略化し、コードの可読性とメンテナンス性を高めるために使用される.
JSTLはSUN(Oracle)が仕様を定義し、Apache Tomcatチームが実現する.
JSTLコアライブラリの参照コアラベルライブラリ(Core)はJSTLの最も重要なラベルライブラリであり、JSTLの基礎機能 を提供している.
JSTL標準ラベルライブラリ;
JSTLはJSPの開発を簡略化し、コードの可読性とメンテナンス性を高めるために使用される.
JSTLはSUN(Oracle)が仕様を定義し、Apache Tomcatチームが実現する.
JSTLコアライブラリの参照
JSTL taglibs-standard-impl.jar META-INF/c.tld
Insert title here
1-10
11-20
Insert title here
!
MonthServlet.java
package jstl;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class MonthServlet
*/
@WebServlet("/month")
public class MonthServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public MonthServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Set setMonths = new HashSet();
setMonths.add("January");
setMonths.add("February");
setMonths.add("March");
setMonths.add("April");
setMonths.add("May");
request.setAttribute("months", setMonths);
request.getRequestDispatcher("/month.jsp").forward(request, response);
}
}
month.jsp
Insert title here
${idx.index + 1} —— ${c }
c:out
- (Core)
(nothing=null) nullである を「なし」 に する.-
ブラウザは せずhtmlソースコードを に する.
fmtフォーマットラベルライブラリ- fmtフォーマットラベルライブラリURI:
http://java.sun.com/jsp/jstl/fmt
-
フォーマット ラベル -
フォーマットデジタルタグ formatDate pattern
yyyy
MM
2か .
dd
ふたりの
HH
24
hh
12
mm
ss
SSS
ミリ
formatNumber pattern - "0.00":2 の
を - 「0000.00」:3 で られ、2 の
を します.