﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Colorful Day-随笔分类-MVC Framework</title><link>http://www.blogjava.net/blueoxygen/category/3743.html</link><description>Blue keywords,Green comment,Red breakpoint,my life is also colorful</description><language>zh-cn</language><lastBuildDate>Sat, 03 Mar 2007 09:22:44 GMT</lastBuildDate><pubDate>Sat, 03 Mar 2007 09:22:44 GMT</pubDate><ttl>60</ttl><item><title>[collection]struts download Action</title><link>http://www.blogjava.net/blueoxygen/archive/2005/12/07/22894.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Wed, 07 Dec 2005 09:21:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2005/12/07/22894.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/22894.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2005/12/07/22894.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/22894.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/22894.html</trackback:ping><description><![CDATA[虽然struts上传下载文件很简单，但是封装一下还是好地。<BR><FONT color=#808080><SPAN class=coMULTI>/*<BR>* $Id: DownloadAction.java 164530 2005-04-25 03:11:07Z niallp $<BR>*<BR>* Copyright 2004-2005 The Apache Software Foundation.<BR>*<BR>* Licensed under the Apache License, Version 2.0 (the "License");<BR>* you may not use this file except in compliance with the License.<BR>* You may obtain a copy of the License at<BR>*<BR>*&nbsp; &nbsp; &nbsp; http://www.apache.org/licenses/LICENSE-2.0<BR>*<BR>* Unless required by applicable law or agreed to in writing, software<BR>* distributed under the License is distributed on an "AS IS" BASIS,<BR>* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<BR>* See the License for the specific language governing permissions and<BR>* limitations under the License.<BR>*/</SPAN><BR><BR><BR></FONT>package org.<SPAN class=me1><FONT color=#006600>apache</FONT></SPAN>.<SPAN class=me1><FONT color=#006600>struts</FONT></SPAN>.<SPAN class=me1><FONT color=#006600>actions</FONT></SPAN>;<BR><BR><FONT color=#a1a100><SPAN class=co2>import java.io.BufferedInputStream;</SPAN><BR><SPAN class=co2>import java.io.File;</SPAN><BR><SPAN class=co2>import java.io.FileInputStream;</SPAN><BR><SPAN class=co2>import java.io.IOException;</SPAN><BR><SPAN class=co2>import java.io.InputStream;</SPAN><BR><SPAN class=co2>import java.io.OutputStream;</SPAN><BR><BR><SPAN class=co2>import javax.servlet.ServletContext;</SPAN><BR><SPAN class=co2>import javax.servlet.http.HttpServletRequest;</SPAN><BR><SPAN class=co2>import javax.servlet.http.HttpServletResponse;</SPAN><BR><BR><SPAN class=co2>import org.apache.struts.action.Action;</SPAN><BR><SPAN class=co2>import org.apache.struts.action.ActionForm;</SPAN><BR><SPAN class=co2>import org.apache.struts.action.ActionForward;</SPAN><BR><SPAN class=co2>import org.apache.struts.action.ActionMapping;</SPAN><BR><BR><BR></FONT><FONT color=#808080><SPAN class=coMULTI>/**<BR>* This is an abstract base class that minimizes the amount of special coding<BR>* that needs to be written to download a file. All that is required to use<BR>* this class is to extend it and implement the &lt;code&gt;getStreamInfo()&lt;/code&gt;<BR>* method so that it returns the relevant information for the file (or other<BR>* stream) to be downloaded. Optionally, the &lt;code&gt;getBufferSize()&lt;/code&gt;<BR>* method may be overridden to customize the size of the buffer used to<BR>* transfer the file.<BR>*<BR>* @since Struts 1.2.6<BR>*/</SPAN><BR></FONT><SPAN class=kw2><STRONG>public</STRONG></SPAN> <SPAN class=kw2><STRONG>abstract</STRONG></SPAN> <SPAN class=kw2><STRONG>class</STRONG></SPAN> DownloadAction <SPAN class=kw2><STRONG>extends</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AAction+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>Action</FONT></STRONG></SPAN></A> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR><BR></FONT>&nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp;* If the &lt;code&gt;getBufferSize()&lt;/code&gt; method is not overridden, this is<BR>&nbsp; &nbsp; &nbsp;* the buffer size that will be used to transfer the data to the servlet<BR>&nbsp; &nbsp; &nbsp;* output stream.<BR>&nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; <SPAN class=kw2><STRONG>protected</STRONG></SPAN> <SPAN class=kw4><FONT color=#993333>static</FONT></SPAN> <SPAN class=kw2><STRONG>final</STRONG></SPAN> <SPAN class=kw4><FONT color=#993333>int</FONT></SPAN> DEFAULT_BUFFER_SIZE = <SPAN class=nu0><FONT color=#cc66cc>1024</FONT></SPAN> * <SPAN class=nu0><FONT color=#cc66cc>4</FONT></SPAN>;<BR><BR>&nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp;* Returns the information on the file, or other stream, to be downloaded<BR>&nbsp; &nbsp; &nbsp;* by this action. This method must be implemented by an extending class.<BR>&nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp;* @param mapping&nbsp; The ActionMapping used to select this instance.<BR>&nbsp; &nbsp; &nbsp;* @param form&nbsp; &nbsp; &nbsp;The optional ActionForm bean for this request (if any).<BR>&nbsp; &nbsp; &nbsp;* @param request&nbsp; The HTTP request we are processing.<BR>&nbsp; &nbsp; &nbsp;* @param response The HTTP response we are creating.<BR>&nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp;* @return The information for the file to be downloaded.<BR>&nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp;* @throws Exception if an exception occurs.<BR>&nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; <SPAN class=kw2><STRONG>protected</STRONG></SPAN> <SPAN class=kw2><STRONG>abstract</STRONG></SPAN> StreamInfo getStreamInfo<SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>ActionMapping mapping,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ActionForm form, HttpServletRequest request,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpServletResponse response<FONT color=#66cc66><SPAN class=br0>)</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>throws</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>Exception</FONT></STRONG></SPAN></A>;<BR><BR>&nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp;* Returns the size of the buffer to be used in transferring the data to<BR>&nbsp; &nbsp; &nbsp;* the servlet output stream. This method may be overridden by an extending<BR>&nbsp; &nbsp; &nbsp;* class in order to customize the buffer size.<BR>&nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp;* @return The size of the transfer buffer, in bytes.<BR>&nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; <SPAN class=kw2><STRONG>protected</STRONG></SPAN> <SPAN class=kw4><FONT color=#993333>int</FONT></SPAN> getBufferSize<FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN></FONT> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>return</STRONG></SPAN> DEFAULT_BUFFER_SIZE;<BR>&nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><BR></FONT>&nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp;* Process the specified HTTP request, and create the corresponding HTTP<BR>&nbsp; &nbsp; &nbsp;* response (or forward to another web component that will create it).<BR>&nbsp; &nbsp; &nbsp;* Return an &lt;code&gt;ActionForward&lt;/code&gt; instance describing where and how<BR>&nbsp; &nbsp; &nbsp;* control should be forwarded, or &lt;code&gt;null&lt;/code&gt; if the response has<BR>&nbsp; &nbsp; &nbsp;* already been completed.<BR>&nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp;* @param mapping&nbsp; The ActionMapping used to select this instance.<BR>&nbsp; &nbsp; &nbsp;* @param form&nbsp; &nbsp; &nbsp;The optional ActionForm bean for this request (if any).<BR>&nbsp; &nbsp; &nbsp;* @param request&nbsp; The HTTP request we are processing.<BR>&nbsp; &nbsp; &nbsp;* @param response The HTTP response we are creating.<BR>&nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp;* @throws Exception if an exception occurs.<BR>&nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> ActionForward execute<SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>ActionMapping mapping, ActionForm form,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpServletRequest request, HttpServletResponse response<FONT color=#66cc66><SPAN class=br0>)</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>throws</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>Exception</FONT></STRONG></SPAN></A> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; StreamInfo info = getStreamInfo<SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>mapping, form, request, response<SPAN class=br0><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>String</FONT></STRONG></SPAN></A> contentType = info.<SPAN class=me1><FONT color=#006600>getContentType</FONT></SPAN><FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN></FONT>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl%3AInputStream+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>InputStream</FONT></STRONG></SPAN></A> stream = info.<SPAN class=me1><FONT color=#006600>getInputStream</FONT></SPAN><FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN></FONT>;<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>try</STRONG></SPAN> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<SPAN class=me1><FONT color=#006600>setContentType</FONT></SPAN><SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>contentType<SPAN class=br0><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; copy<SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>stream, response.<SPAN class=me1><FONT color=#006600>getOutputStream</FONT></SPAN><FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN><SPAN class=br0>)</SPAN></FONT>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=br0><FONT color=#66cc66>}</FONT></SPAN> <SPAN class=kw2><STRONG>finally</STRONG></SPAN> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw1><FONT color=#b1b100>if</FONT></SPAN> <SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>stream != <SPAN class=kw2><STRONG>null</STRONG></SPAN><SPAN class=br0><FONT color=#66cc66>)</FONT></SPAN> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<SPAN class=me1><FONT color=#006600>close</FONT></SPAN><FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN></FONT>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=co1>// Tell Struts that we are done with the response.</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>return</STRONG></SPAN> <SPAN class=kw2><STRONG>null</STRONG></SPAN>;<BR>&nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><BR></FONT>&nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp;* Copy bytes from an &lt;code&gt;InputStream&lt;/code&gt; to an<BR>&nbsp; &nbsp; &nbsp;* &lt;code&gt;OutputStream&lt;/code&gt;.<BR>&nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp;* @param input&nbsp; The &lt;code&gt;InputStream&lt;/code&gt; to read from.<BR>&nbsp; &nbsp; &nbsp;* @param output The &lt;code&gt;OutputStream&lt;/code&gt; to write to.<BR>&nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp;* @return the number of bytes copied<BR>&nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp;* @throws IOException In case of an I/O problem<BR>&nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> <SPAN class=kw4><FONT color=#993333>int</FONT></SPAN> copy<SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN><A href="http://www.google.com/search?q=allinurl%3AInputStream+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>InputStream</FONT></STRONG></SPAN></A> input, <A href="http://www.google.com/search?q=allinurl%3AOutputStream+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>OutputStream</FONT></STRONG></SPAN></A> output<FONT color=#66cc66><SPAN class=br0>)</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>throws</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>IOException</FONT></STRONG></SPAN></A> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw4><FONT color=#993333>byte</FONT></SPAN><FONT color=#66cc66><SPAN class=br0>[</SPAN><SPAN class=br0>]</SPAN></FONT> buffer = <SPAN class=kw2><STRONG>new</STRONG></SPAN> <SPAN class=kw4><FONT color=#993333>byte</FONT></SPAN><SPAN class=br0><FONT color=#66cc66>[</FONT></SPAN>getBufferSize<FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN><SPAN class=br0>]</SPAN></FONT>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw4><FONT color=#993333>int</FONT></SPAN> count = <SPAN class=nu0><FONT color=#cc66cc>0</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw4><FONT color=#993333>int</FONT></SPAN> n = <SPAN class=nu0><FONT color=#cc66cc>0</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw1><FONT color=#b1b100>while</FONT></SPAN> <SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>-<SPAN class=nu0><FONT color=#cc66cc>1</FONT></SPAN> != <SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>n = input.<SPAN class=me1><FONT color=#006600>read</FONT></SPAN><SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>buffer<FONT color=#66cc66><SPAN class=br0>)</SPAN><SPAN class=br0>)</SPAN><SPAN class=br0>)</SPAN></FONT> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<SPAN class=me1><FONT color=#006600>write</FONT></SPAN><SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>buffer, <SPAN class=nu0><FONT color=#cc66cc>0</FONT></SPAN>, n<SPAN class=br0><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count += n;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>return</STRONG></SPAN> count;<BR>&nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><BR></FONT>&nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp;* The information on a file, or other stream, to be downloaded by the<BR>&nbsp; &nbsp; &nbsp;* &lt;code&gt;DownloadAction&lt;/code&gt;.<BR>&nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> <SPAN class=kw4><FONT color=#993333>static</FONT></SPAN> <SPAN class=kw2><STRONG>interface</STRONG></SPAN> StreamInfo <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Returns the content type of the stream to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return The content type of the stream.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> <SPAN class=kw2><STRONG>abstract</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>String</FONT></STRONG></SPAN></A> getContentType<FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN></FONT>;<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Returns an input stream on the content to be downloaded. This stream<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* will be closed by the &lt;code&gt;DownloadAction&lt;/code&gt;.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return The input stream for the content to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> <SPAN class=kw2><STRONG>abstract</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AInputStream+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>InputStream</FONT></STRONG></SPAN></A> getInputStream<FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN></FONT> <SPAN class=kw2><STRONG>throws</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>IOException</FONT></STRONG></SPAN></A>;<BR>&nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><BR></FONT>&nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp;* A concrete implementation of the &lt;code&gt;StreamInfo&lt;/code&gt; interface which<BR>&nbsp; &nbsp; &nbsp;* simplifies the downloading of a file from the disk.<BR>&nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> <SPAN class=kw4><FONT color=#993333>static</FONT></SPAN> <SPAN class=kw2><STRONG>class</STRONG></SPAN> FileStreamInfo <SPAN class=kw2><STRONG>implements</STRONG></SPAN> StreamInfo <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The content type for this stream.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>private</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>String</FONT></STRONG></SPAN></A> contentType;<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The file to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>private</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AFile+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>File</FONT></STRONG></SPAN></A> file;<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Constructs an instance of this class, based on the supplied<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* parameters.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param contentType The content type of the file.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param file&nbsp; &nbsp; &nbsp; &nbsp; The file to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> FileStreamInfo<SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN><A href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>String</FONT></STRONG></SPAN></A> contentType, <A href="http://www.google.com/search?q=allinurl%3AFile+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>File</FONT></STRONG></SPAN></A> file<SPAN class=br0><FONT color=#66cc66>)</FONT></SPAN> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>this</STRONG></SPAN>.<SPAN class=me1><FONT color=#006600>contentType</FONT></SPAN> = contentType;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>this</STRONG></SPAN>.<SPAN class=me1><FONT color=#006600>file</FONT></SPAN> = file;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Returns the content type of the stream to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return The content type of the stream.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>String</FONT></STRONG></SPAN></A> getContentType<FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN></FONT> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>return</STRONG></SPAN> <SPAN class=kw2><STRONG>this</STRONG></SPAN>.<SPAN class=me1><FONT color=#006600>contentType</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Returns an input stream on the file to be downloaded. This stream<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* will be closed by the &lt;code&gt;DownloadAction&lt;/code&gt;.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return The input stream for the file to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AInputStream+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>InputStream</FONT></STRONG></SPAN></A> getInputStream<FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN></FONT> <SPAN class=kw2><STRONG>throws</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>IOException</FONT></STRONG></SPAN></A> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl%3AFileInputStream+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>FileInputStream</FONT></STRONG></SPAN></A> fis = <SPAN class=kw2><STRONG>new</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AFileInputStream+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>FileInputStream</FONT></STRONG></SPAN></A><SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>file<SPAN class=br0><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl%3ABufferedInputStream+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>BufferedInputStream</FONT></STRONG></SPAN></A> bis = <SPAN class=kw2><STRONG>new</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3ABufferedInputStream+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>BufferedInputStream</FONT></STRONG></SPAN></A><SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>fis<SPAN class=br0><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>return</STRONG></SPAN> bis;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR></FONT>&nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><BR></FONT>&nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp;* A concrete implementation of the &lt;code&gt;StreamInfo&lt;/code&gt; interface which<BR>&nbsp; &nbsp; &nbsp;* simplifies the downloading of a web application resource.<BR>&nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> <SPAN class=kw4><FONT color=#993333>static</FONT></SPAN> <SPAN class=kw2><STRONG>class</STRONG></SPAN> ResourceStreamInfo <SPAN class=kw2><STRONG>implements</STRONG></SPAN> StreamInfo <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The content type for this stream.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>private</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>String</FONT></STRONG></SPAN></A> contentType;<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The servlet context for the resource to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>private</STRONG></SPAN> ServletContext context;<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The path to the resource to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>private</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>String</FONT></STRONG></SPAN></A> path;<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Constructs an instance of this class, based on the supplied<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* parameters.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param contentType The content type of the file.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param context&nbsp; &nbsp; &nbsp;The servlet context for the resource.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param path&nbsp; &nbsp; &nbsp; &nbsp; The path to the resource to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> ResourceStreamInfo<SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN><A href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>String</FONT></STRONG></SPAN></A> contentType, ServletContext context,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>String</FONT></STRONG></SPAN></A> path<SPAN class=br0><FONT color=#66cc66>)</FONT></SPAN> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>this</STRONG></SPAN>.<SPAN class=me1><FONT color=#006600>contentType</FONT></SPAN> = contentType;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>this</STRONG></SPAN>.<SPAN class=me1><FONT color=#006600>context</FONT></SPAN> = context;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>this</STRONG></SPAN>.<SPAN class=me1><FONT color=#006600>path</FONT></SPAN> = path;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Returns the content type of the stream to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return The content type of the stream.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>String</FONT></STRONG></SPAN></A> getContentType<FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN></FONT> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>return</STRONG></SPAN> <SPAN class=kw2><STRONG>this</STRONG></SPAN>.<SPAN class=me1><FONT color=#006600>contentType</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN class=coMULTI>/**<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Returns an input stream on the resource to be downloaded. This stream<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* will be closed by the &lt;code&gt;DownloadAction&lt;/code&gt;.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return The input stream for the resource to be downloaded.<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>public</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AInputStream+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>InputStream</FONT></STRONG></SPAN></A> getInputStream<FONT color=#66cc66><SPAN class=br0>(</SPAN><SPAN class=br0>)</SPAN></FONT> <SPAN class=kw2><STRONG>throws</STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&amp;bntl=1"><SPAN class=kw3><STRONG><FONT color=#aaaadd>IOException</FONT></STRONG></SPAN></A> <FONT color=#66cc66><SPAN class=br0>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN class=kw2><STRONG>return</STRONG></SPAN> context.<SPAN class=me1><FONT color=#006600>getResourceAsStream</FONT></SPAN><SPAN class=br0><FONT color=#66cc66>(</FONT></SPAN>path<SPAN class=br0><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR></FONT>&nbsp; &nbsp; <FONT color=#66cc66><SPAN class=br0>}</SPAN><BR><SPAN class=br0>}</SPAN></FONT><BR><img src ="http://www.blogjava.net/blueoxygen/aggbug/22894.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2005-12-07 17:21 <a href="http://www.blogjava.net/blueoxygen/archive/2005/12/07/22894.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts ActionForm-&gt;BO转换方式总结</title><link>http://www.blogjava.net/blueoxygen/archive/2005/10/08/14989.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Sat, 08 Oct 2005 07:40:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2005/10/08/14989.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/14989.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2005/10/08/14989.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/14989.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/14989.html</trackback:ping><description><![CDATA[也算是Struts in Action的读书笔记吧~~~ <BR>1 实现业务层接口<BR>public class ArticleForm extends ActionForm implements ArticleBean{<BR>//...<BR>}<BR>调用ArticleBean articleBean = (ArticleBean)form;<BR>articleModel.update(articleBean.getKey(),articleBean);<BR>2&nbsp; 手动初始化<BR>ArticleForm aForm = (ArticleForm)form;<BR>ArticleBean aBean = new ArticleBean(aFrom.getxxxx..,.,.,.);<BR>4 提供工厂方法<BR>ActionForm中封装此方法<BR>public ArticleBean getArticleBean(){<BR>ArticleBean aBean = new ArticleBean(<BR>this.getXXXX,<BR>this.getXXXX,<BR>......<BR>)<BR>}<BR>5 传递Map对象<BR>用BeanUtils包或者手动产生于ActionForm<BR>public Map describe(){<BR>&nbsp; map = new HashMap();<BR>&nbsp; map.add("xx",this.getXXX());<BR>&nbsp; map.add("xx",this.getXX());<BR>&nbsp;&nbsp;&nbsp; //......<BR>}<BR>6 反射传递数据<BR>写于action<BR>BeanUtils.copyProperties(myBusinessBean,myActionForm);<BR>&nbsp; //Business Object's somemethod<BR>BeanUtils.copyProperties(myActionForm,myBusinessBean);<img src ="http://www.blogjava.net/blueoxygen/aggbug/14989.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2005-10-08 15:40 <a href="http://www.blogjava.net/blueoxygen/archive/2005/10/08/14989.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>打破神话</title><link>http://www.blogjava.net/blueoxygen/archive/2005/10/08/14978.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Sat, 08 Oct 2005 04:13:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2005/10/08/14978.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/14978.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2005/10/08/14978.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/14978.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/14978.html</trackback:ping><description><![CDATA[我什么时候也起这么恶心的题目了，可能和某些同志混久了，也喜欢抓眼球了。言归正传，banq老爷子(这么叫挺可爱的)，就是jdon创始的那个banq，其实我一直有些佩服有些BS的复杂情绪看待这样一个人，banq技术上确实有几下，起码不是只会吵架的人，能研究些东西，但是，看他吵架和写东西确实不是很舒服，总是感觉什么东西都是他banq的最好，他的jdonframework比spring先进阿，HiveMind框架的思想他早就有啊之类的……翻翻帖子，看看gigix robbin怎么和banq结的梁子，有时候不禁喷饭。但是似乎所有大牛都有个特点，什么东西都要评头品足，我就纳闷，世界上有这样的人么？什么东西都研究的明明白白的。今天好不容易闲了，去jdon看看热闹，看有人吵架每(这心里够bt)，结果看到banq解答的struts问题的帖子，sigh，要是普通人我早就反驳了，可是因为是banq，我又再次翻出来以前看的资料和源码才敢指出:banq,u r wrong.而且是很基础的很本质的错误。问题如下：<BR><FONT color=#333399>感觉Struts标签太繁琐了，想用 struts+velocity ,但是页面如果没有html:form等struts标签，页面的form elements 是否能赋值到formbean中，formbean中的validate方法是否还有效。<BR></FONT><FONT color=#000000>banq的理解：<BR><FONT color=#993300><FONT face=Arial size=2>当然不会有效。每个字段实际是通过：</FONT><BR>&lt;html:text name=<FONT size=3>"ACTIONFORM名称" propert=""</FONT><BR>其中name很重要，指定了使用哪个ActionForm。<BR></FONT></FONT><FONT color=#000000>俺给个解答，也请指出不足和理解上的偏颇：<BR></FONT><FONT color=#333333><FONT face=Arial size=2>name:The attribute name of the bean whose properties are consulted when rendering the current value of this input field. If not specified, the bean associated with the form tag we are nested within is utilized. <BR>Any JavaBean can be used with the Struts JSP tags to populate a control. But to provide automatic validation of the input, Struts uses its own JavaBean subclass,called the ActionForm.<BR><STRONG>The ActionForm solution</STRONG><BR>The Struts solution to HTTP parameter handling is to transform the input fields into JavaBean properties. When a property on the ActionForm matches a parameter in the request, the framework automatically sets the property to the value of the parameter. A Struts developer can work with a trusty JavaBean and leave the HTTP rigmarole to the framework.To harvest request parameters, all the Struts developer needs to do is provide an ActionForm with JavaBean properties that match the names of the HTTP parameters. The rest is automatic.</FONT><BR>具体如何automatic解析，ActionForm如何被控制，有空再写，毕竟struts研究的系列心得才进行了很少篇blog，现在忙着webwork2 hibernate spring</FONT><img src ="http://www.blogjava.net/blueoxygen/aggbug/14978.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2005-10-08 12:13 <a href="http://www.blogjava.net/blueoxygen/archive/2005/10/08/14978.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>