1、引入jar包
index页面:作用点击连接调用页面
<a href="servlet/JstlCoreServlet">测试JSTL核心库</a><br>
JstlCoreServlet类,作用:存储数据,转发页面!
package com.bjpowernode.jstl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class JstlCoreServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//普通字符串
request.setAttribute("hello", "Hello World");
request.getRequestDispatcher("/jstl_core.jsp").forward(request, response);
}
}
jstl_core.jap页面
<%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>Insert title here</title> </head> <body> <hl>测试JSTL核心库</hl> <hr> <li>采用c:out标签</li><br> hell(使用标签):<c:out value="123"/> </body> </html>
引入jar包路径:
其中的jar包在文件中查找!