JSTL은 JSP(Java Server Pages)의 추가 확장인 Java Standard Tag Library로 축약됩니다. JSTL은 개발자를 위한 코드 줄을 줄였습니다. 이 JSTL은 조건부 및 반복과 같은 일반적인 작업인 구조적 작업을 지원합니다. 이러한 태그는 I18N(국제화) 태그, SQL 태그, XML 문서 등을 변경하는 데 사용됩니다. 이는 또한 Java 표준 태그 라이브러리 내에 기존 사용자 정의 태그를 연결하기 위한 프레임워크를 제공합니다.
무료 소프트웨어 개발 과정 시작
웹 개발, 프로그래밍 언어, 소프트웨어 테스팅 등
JSTL의 장점:
- 빠른 개발.
- 코드 재사용성.
- 스크립틀릿 태그를 사용할 필요가 없습니다.
JSTL은 Java에서 어떻게 작동하나요?
JSTL은 애플리케이션에서 사용한 태그 유형을 기반으로 작동합니다. 약 5가지 유형의 태그로 구성됩니다. 그들은
- 핵심 태그
- 함수 태그
- 태그 서식 지정
- XML 태그
- SQL 태그
JSTL 태그 설명:
Tag Type | Description | URI to include | prefix |
Core tags | The JSTL core tag provides flow control, variable support, URL management etc. | http://java.sun.com/jsp/jstl/core | c |
Function tags | This function tag is used for String manipulation and String length |
http://java.sun.com/jsp/jstl/ functions |
fn |
Formatting tags | This formatting tag is used for number, date and message formatting | http://java.sun.com/jsp/jstl/fmt | fmt |
XML tags | This XML tag is used for transformation and flow control etc. | http://java.sun.com/jsp/jstl/xml | x |
SQL tags | This SQL tag is used to provide support for SQL support. | http://java.sun.com/jsp/jstl/sql | sql |
문자열 길이
기능
각 JSTL 태그는 다시 서로 다른 하위 태그로 구성됩니다. 이제 핵심 태그와 기능 태그의 몇 가지 예를 살펴보겠습니다.
참고: 다음 기능을 활용하세요. jstl.1.X.jar 파일을 사용해야 합니다. X는 버전을 나타냅니다.예
아래 예시는 다음과 같습니다.
Eclipse의 프로젝트 구조:
예 #1 – 핵심 태그 c:out
코드: NewFile.jsp
<title>JSTL Tags</title> <!--THis c:out tag is used for displaying output--> <out value="${'Hello Amardeep, Wel come to EDUCBA online courses.'}"></out>
출력:
예 #2 – 핵심 태그 세트 및 c:if 태그
코드: SetCIf.jsp
<title>JSTL Tags</title> <set var="money" scope="session" value="${5000*5}"></set> <if test="${money > 8000}"> <p>My Salary is: <out value="${money}"></out></p> <p> </p></if>
출력:
예 #3 – c:choose 태그가 포함된 코어 태그
코드: CChoose.jsp
<title>JSTL Tags</title> <set var="money" scope="session" value="${5000*5}"></set> <p>Your income is : <out value="${money}"></out></p> <choose> <when test="${money <= 1000}"> You are paid with good salary. </when> <when test="${money > 10000}"> You are paid with really good salary. </when> <otherwise> You are paid with low salary . </otherwise> </choose>
출력:
예 #4 – c:when 태그가 포함된 핵심 태그
코드: CWhen.jsp
<title>JSTL Tags</title> <set value="214" var="digit"></set> <choose> <when test="${digit%2==0}"> <out value="${digit} is EVEN digit"></out> </when> <otherwise> <out value="${digit} is ODD digit"></out> </otherwise> </choose>
출력:
예 #5 – c:foreach 태그가 포함된 핵심 태그
코드: CForeach.jsp
<title>JSTL Tags</title> <foreach var="iterator" begin="100" end="110"> Count: <out value="${iterator}"></out> <p> </p></foreach>
출력:
예 #6 – c:forTokens 태그가 있는 핵심 태그
코드: CForTokens.jsp
<title>JSTL Tags</title> <fortokens items="My-Name-is-Nathi-Paramesh" delims="-" var="del"> Word: <out value="${del}"></out> <p> </p></fortokens>
출력:
예 # 7 – c:redirect 태그가 포함된 핵심 태그
코드: CRedirect.jsp
<title>JSTL Tags</title> <set var="urlName" value="2" scope="request"></set> <if test="${urlName<1}"> <redirect url="http:/educba.com"></redirect> </if> <!-- Page directly redirect to gmail because value is greater than 1 --> <if test="${urlName>1}"> <redirect url="http://gmail.com"></redirect> </if>
출력:
예 #8 – c:contains 태그가 있는 함수 태그
코드: FunctionContains.jsp
<title>JSTL Tags</title> <set var="StringType" value="We are learning online course from EDUCBA platform"></set> <if test="${fn:contains(StringType, 'EDUCBA')}"> <h1 style="color: green">Yes Given String found in the value </h1> <p style="color:blue;border: 1px solid red;font-size:20px">JSTL abbreviated as Java Standard Tag Library. Which is further extension for JSP (Java Server Pages). JSTL reduced the lines of code for developer. This JSTL supports for structural tasks, common task like conditional and iteration. This tags used for changing I18N (Internationalization) tags, SQL tags, XML documents etc. This JSTL also provides a framework for attaching the already existing custom tags within the Java Standard Tag Library.</p> </if> <if test="${fn:contains(StringType, 'courses')}"> <p>No Given String is not found in the value </p> <p> </p></if>
출력:
예 # 9 – c:endsWith 태그가 있는 함수 태그
코드: CEndsWith.jsp
<title>JSTL Tags</title> <set var="StringType" value="We are learning online course from EDUCBA platform"></set> <if test="${fn:endsWith(StringType, 'platform')}"> <h1 id="Yes-String-ends-with-platfrom">Yes String ends with platfrom.</h1> <p style="color: fuchsia; border: 1px solid red; font-size: 20px">JSTL abbreviated as Java Standard Tag Library. Which is further extension for JSP (Java Server Pages). JSTL reduced the lines of code for developer. This JSTL supports for structural tasks, common task like conditional and iteration. This tags used for changing I18N (Internationalization) tags, SQL tags, XML documents etc. This JSTL also provides a framework for attaching the already existing custom tags within the Java Standard Tag Library.</p> </if> <if test="${fn:endsWith(String, 'are')}"> <p>String ends with are. </p> <p> </p></if>
출력:
위 내용은 자바의 JSTL의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

Dreamweaver Mac版
시각적 웹 개발 도구

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.
