posts - 32,comments - 8,trackbacks - 0
 

Oops! JSTL Quick Start

Purpose:

掌握jstl入门

Precondition:

eclipse-java-europa-win32.zip

/Files/pixysoft/jakarta-taglibs-standard-current.zip

Tutorial

新建一个Dynamic Web Project,名字叫做Oops_jstl



WebContent/WEB-INF/lib下添加以下jar文件,全部可以在jakarta-taglibs-standard-current.zip里面找到。



webContent/WEB-INF下新建一个tlds目录,添加以下文件



修改web.xml,添加以下内容

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"

    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation
="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

    version
="2.4">

    
<jsp-config>

       
<taglib>

           
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>

           
<taglib-location>/WEB-INF/tlds/c.tld</taglib-location>

       
</taglib>

    
</jsp-config>

</web-app>



在WebContent目录下面添加index.jsp文件

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

<html>

 
<body>

    
<c:if test="${pageContext.request.method=='POST'}">

      
<c:if test="${param.guess=='java'}">You guessed it!

      
<br />

      
<br />

      
</c:if>

      
<c:if test="${param.guess!='java'}">

      You are wrong

      
<br />

      
<br />

      
</c:if>

    
</c:if>

    
<form method="post">Guess what computer language

                        I am thinking of?

    
<input type="text" name="guess" />

    
<input type="submit" value="Try!" />

    
<br />

    
</form>

 
</body>

</html>



运行!




成功!

posted on 2007-09-01 20:09 张辰 阅读(198) 评论(0)  编辑  收藏 所属分类: Dr. Oops

只有注册用户登录后才能发表评论。


网站导航: