About jstl in JSP

Source: Internet
Author: User
Tags tld

Today, when I used the jstl tag library in JSP, I encountered a very disgusting problem. I remember when I took this course at school a few years ago, I have never encountered this kind of problem. It's really disgusting to see it now.

Generally, the following error occurs when you are not careful:

The absolute URI: http://java.sun.com/jstl/core cannot be resolved. An example such as: http://stackoverflow.com/questions/4928271/jstl-1-2-the-absolute-uri-http-java-sun-com-jstl-core-cannot-be-resolved

Solution:

If your project is managed using Maven, you can easily add the following content to the Pom. xml file:

 
<Dependency> <groupid> jstl </groupid> <artifactid> jstl </artifactid> <version> 1.1.2 </version> </dependency> <groupid> taglibs </ groupid> <artifactid> Standard </artifactid> <version> 1.1.2 </version> </dependency>

Then add the following in your JSP file:

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

OK.

Of course, if your project is not managed using Maven, You can manually add support. The specific method is:

First go to http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/ downloadThe release file of the standard tag library.

To use the java standard tag library in JSP, You need:

1. Copy the TLD file to the WEB-INF/TLD
2. Copy JAR file to WEB-INF/lib

 

A simple example is as follows:

 

<% @ Page Language = "Java" contenttype = "text/html; charset = UTF-8 "%> <% @ taglib uri ="/WEB-INF/TLD/c-rt.tld "prefix =" C-RT "%> <HTML>  

Note that the above exampleCodeThis line:

 
<%@ Taglib uri = "/WEB-INF/TLD/c-rt.tld" prefix = "C-RT" %>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.