tomcat5.5.17+jstl1.2+servlet2.5+jsp2.1配置在此我使用的環(huán)境是:tomcat5.5.17jstl1.2servlet2.5jsp2.1我以一個簡單的例子hello1來說明吧,發(fā)布工程時最重要的就是目錄結(jié)構(gòu)了,hello1是根目錄,放在tomcat中的webapps里,先看看目錄結(jié)構(gòu):hello1\index.jsphello1\response.jsphello1\WEB-INF\lib\javaee.jarhello1\WEB-INF\lib\jsf-api.jarhello1\WEB-INF\lib\jsf-impl.jarhello1\WEB-INF\lib\jstl-1.2.jarhello1\WEB-INF\web.xml如果你按照以上目錄發(fā)布工程,拋出以下異常:(1) java.lang.NoClassDefFoundError: javax/el/ExpressionFactory(2) 或打開頁面后顯示:
type Status report
message /hello1/
description The requested resource (/hello1/) is not available.
則將javaee.jar包再copy一份放在tomcat目錄的common\lib下就不會了。關(guān)于用到的javaee.jar、jsf-api.jar、jsf-impl.jar、jstl-1.2.jar這四個包可以通過myeclipse中獲得,如果你安裝了myeclipse5.5的話,我安裝的是MyEclipse 5.5.1 GA,這四個包的所在的目錄是:MyEclipse 5.5.1 GA\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.1\data\libraryset\EE_5\到此,再給出具體的文件代碼吧。(1) hello1\index.jsp<%@ taglib uri="<%@ taglib uri=" <html><head><title>Hello</title></head><body bgcolor="white"><h2>Hello, my name is Duke. What's yours?</h2><form method="get"><input type="text" name="username" size="25"><p></p><input type="submit" value="Submit"><input type="reset" value="Reset"></form> <c:if test="${fn:length(param.username) > 0}" > <%@include file="response.jsp" %></c:if></body></html>(2) hello1\response.jsp<h2><font color="black">Hello, ${param.username}!</font></h2>(3) hello1\WEB-INF\web.xml<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns=" xmlns:xsi=" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_2_5.xsd" version="2.5"> <jsp-config> <jsp-property-group> <display-name>hello1</display-name> <url-pattern>*.jsp</url-pattern> <el-ignored>false</el-ignored> <scripting-invalid>false</scripting-invalid> <is-xml>false</is-xml> <!-- <include-prelude>/template/prelude.jspf</include-prelude> --> <!-- <include-coda>/template/coda.jspf</include-coda> --> </jsp-property-group> </jsp-config></web-app> 成功之后頁面顯示為: Hello, my name is Duke. What's yours? Hello, afdfadsfads! posted on 2007-07-06 13:35 landril 閱讀(3810) 評論(0) 編輯 收藏 所屬分類: Jsp&Servlet
<html><head><title>Hello</title></head><body bgcolor="white"><h2>Hello, my name is Duke. What's yours?</h2><form method="get"><input type="text" name="username" size="25"><p></p><input type="submit" value="Submit"><input type="reset" value="Reset"></form>
<c:if test="${fn:length(param.username) > 0}" > <%@include file="response.jsp" %></c:if></body></html>(2) hello1\response.jsp<h2><font color="black">Hello, ${param.username}!</font></h2>(3) hello1\WEB-INF\web.xml<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns=" xmlns:xsi=" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_2_5.xsd" version="2.5">
<jsp-config> <jsp-property-group> <display-name>hello1</display-name> <url-pattern>*.jsp</url-pattern> <el-ignored>false</el-ignored> <scripting-invalid>false</scripting-invalid> <is-xml>false</is-xml> <!-- <include-prelude>/template/prelude.jspf</include-prelude> --> <!-- <include-coda>/template/coda.jspf</include-coda> --> </jsp-property-group> </jsp-config></web-app>
posted on 2007-07-06 13:35 landril 閱讀(3810) 評論(0) 編輯 收藏 所屬分類: Jsp&Servlet