私は JSP が初めてで、式言語を使用しています。バージョン 2.5 および Tomcat 6 サーバーで Eclipse Galileo を使用しています。私の単純な式言語は${1>2}
、false を与えると仮定して書いた場合のように値を出力していませんが ${1>2}
、ページをレンダリングするときにのみ表示されていることを尋ねたいだけです。しかし、私が使用し<c:out value="${1>2}"/>
ているときは正しく印刷されていません。タグライブラリに問題があると思います。私が間違っている場所を理解できるように、このサンプルコードを提供しているので、その理由を親切に教えてください:-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/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=ISO-8859-1">
<title>Expression Language Example</title>
</head>
<body>
Is 1 greater than 2 using cout :<c:out value="${1>2}"/>
Is 1 greater than 2 without using cout: ${1>2}
</body>
</html>
回答に従って更新します。詳細は次のとおりです。
私はweb.xml
それがどのように見えるかを示しています:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>ScriptLessJsp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>ElServlet</display-name>
<servlet-name>ElServlet</servlet-name>
<servlet-class>com.servlet.El.ElServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ElServlet</servlet-name>
<url-pattern>/ElServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>Collections</display-name>
<servlet-name>Collections</servlet-name>
<servlet-class>com.servlet.El.Collections</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Collections</servlet-name>
<url-pattern>/go</url-pattern>
</servlet-mapping>
</web-app>
そして、lib フォルダーに追加jstl.jar
したのは、タグを使用して表示できるようにするためだけ<c:out>
ですが、テンプレート テキストの EL が機能していません。