struts2是不错的,但其标签由于目前dw等工具没好的支持,即使是myeclipse也是支持不好,所以还是不大方便,
但freemarker和jstl还是很精彩的东西,比如有如下的一个应用,象列表类的东西,用freemarker是不错的选择
table align="center">
<tr align="center">
<td>
<select name="searchName">
<option value="bookName">书名</option>
<option value="bookAuthor">作者</option>
<option value="bookPublish">出版社</option>
<option value="bookDate">出版日期</option>
<option value="bookIsbn">ISNB</option>
<option value="bookPage">页数</option>
</select>
<input type="text" name="searchValue" value="" size="10"/>
<input type="button" value="查询" onClick="doSearch();">
</td>
</tr>
<tr align="center">
<td>
<a href="list.action">全部</a>
<a href="edit.action">增加</a>
</td>
</tr>
<tr>
<td>
<table cellspacing="0" align="center">
<thead>
<tr>
<th>书名</th>
<th>作者</th>
<th>出版社</th>
<th>出版日期</th>
<th>ISNB</th>
<th>页数</th>
<th>价格</th>
<th>内容提要</th>
<th>删除</th>
</tr>
</thead>
<tbody>
<#list availableItems as book>
<tr class="trs">
<td>
<a href="/bookAdmin/edit.action?bookId=${book.bookId}">${book.bookName}</a>
</td>
<td> ${book.bookAuthor}</td>
<td> ${book.bookPublish}</td>
<td> ${book.bookDate?string("yyyy-MM-dd")}</td>
<td> ${book.bookIsbn}</td>
<td> ${book.bookPage}</td>
<td> ${book.bookPrice}</td>
<td> ${book.bookContent}</td>
<td><a href='delete.action?bookId=${book.bookId}' onClick="confirmdel(this)"> 删除</a></td>
</tr>
</#list>
但如何是一个普通注册的页面,用freemarker的话,象form等又要引入struts2的标签,不划算,倒不如用JSTL了.
tomcat 6下,配好web.xml
<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">
注意我们的容器要用2.4的了.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<form name="editForm" action="/bookAdmin/save.action" method="post">
<p>
<input type="text" name="book.bookName" value="${book.bookName}"/>
<br>
<input type="text" name="book.bookAuthor" value="${book.bookAuthor}"/>
<br>
<input type="text" name="book.bookPublish" value="${book.bookPublish}"/>
<br>
<fmt:formatDate var="bookDate" value="${book.bookDate}" pattern="yyyy-MM-dd"/>
<input type="text" name="book.bookDate" value="${bookDate}" onfocus="new WdatePicker(this)"/>
<br>
<input type="text" name="book.bookIsbn" value="${book.bookIsbn}"/>
注意这里用fmt把数据库中的日期读出来并且格式化了,