1、一个WEB应用程序的所必须的目录结构为:WEB-INF/lib,WEB-INF/classes, 以及一个部署文件:web.xml。
2、写得任何一个Servlet或JSP页面,要想让它们直接运行,须在部署文件web.xml配置好,Servlet的配置标记为:<servlet/>和<servlet-map/>,而JSP文件的配置标记为:<jsp-config/>下面的子元素<jsp-property-group/>。我这里写的是最基本的,详细配置需参考web.xml文件对应的DTD文件。
3、今天用MYECLIPSE3.2+TOMCAT5.5写了测试页面,居然发现自己现在对JSP语法很是陌生,看来书还是得常看,有事没事就应该去翻翻。我的写JSP页面如下:
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ page import="test.Person" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<%out.println(basePath); %>
<title>My JSP 'MyJsp.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
ArrayList list = new ArrayList(6);
Person p = new Person("xionghuayun","Male",23);
list.add(p);
request.setAttribute( "test", list );
%>
<display:table name="test" />
</body>
</html>
对应的web.xml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
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">
<jsp-config>
<taglib>
<taglib-uri>http://displaytag.sourceforge.net/</taglib-uri>
<taglib-location>/WEB-INF/displaytag-11.tld</taglib-location>
</taglib>
<jsp-property-group>
<url-pattern>/TestDisplayTag.jsp</url-pattern>
<url-pattern>/MyJsp.jsp</url-pattern>
</jsp-property-group>
</jsp-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
4、好啦,今天就写到这里,每天坚持,一天一点。