<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-86  評論-33  文章-0  trackbacks-0
    <html:link>
      
    用于生成HTML<a>元素。用<html:link>創(chuàng)建超鏈接時,有兩個優(yōu)點:
      1、容許在url中以多種方式包含請求參數(shù)。
      2、當用戶瀏覽器關(guān)閉Cookie時,會自動重寫url,把SessionID作為請求參數(shù)包含在URL中,以跟蹤用戶會話。
     
     屬性:
            forward :指定全局轉(zhuǎn)發(fā)鏈接(使用struts-config.xml中的<global-forward>元素中的<forward>元素)
            href:指定完整的URL鏈接
            page:指定相對于當前網(wǎng)頁的URL
    1.創(chuàng)建全局轉(zhuǎn)發(fā)鏈接
      <global-forwards>
        
    <forward name="index" path="/index.jsp" />
      
    </global-forwards>
    <html:link forward="index">
      GLOBAL LINK
    </html:link>
    標簽中forward屬性與<global-forward>元素中的<forward>元素匹配,以上代碼生成
    <a href="/index.jsp">GLOBAL LINK</a>

    2.創(chuàng)建完整的URL鏈接
    <html:link href="http://m.tkk7.com/envoydada">
    BLOGJAVA
    </html:link>
    生成代碼 :
    <a href="http://m.tkk7.com/envoydada">BLOGJAVA</a>
    3.從當前網(wǎng)頁創(chuàng)建相對URL
    <html:link page="/login.do">
      LOGIN
    </html:link>

    <html:multibox>
      復(fù)選框,對應(yīng)的ActionFormBean 中定義一個數(shù)組來接收
    //formbean中定義數(shù)組
    private String a[] = new String[0];
    public String[] getA(){return a[];}
    public void setA(String arr[]){this.a = arr;}
    <html:multibox property = "a" value="dada" />
    <html:multibox property = "a" value="derek"/>
    被選中的復(fù)選框?qū)⒅堤峤唤oActionFormBean中的數(shù)組中,沒選中的就不會包含

    <html:file>
         實現(xiàn)文件上傳功能
         1. jsp代碼 
    <html:form action="/fileAction.do" method="POST" enctype="multipart/form-data">
       
    <html:file property="file" />
       
    <html:submit property="submit" value="Submit"/><br>
       
    <html:reset value ="Reset"/>
    </html:form>
        2. ActionFormBean
    formbean中必須定義一個與頁面<html:file property="file" >屬性對應(yīng)的屬性file,且這個屬性的類型為
    org.apache.struts.upload.Formfile類型
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.*;
    import org.apache.struts.upload.FormFile;

    public class FileActionForm extends ActionForm {
        
    private FormFile file;
        
    public ActionErrors validate(ActionMapping actionMapping,
                                     HttpServletRequest httpServletRequest) {          
            
    return null;}
        
    public void reset(ActionMapping actionMapping,HttpServletRequest servletRequest) {}
        
    public void setFile(FormFile file) {this.file = file;}
        
    public FormFile getFile() {return file;}
    }
    3.在action類中處理文件上傳
    public class FileAction extends Action {
        
    public ActionForward execute(ActionMapping actionMapping,
                                     ActionForm actionForm,
                                     HttpServletRequest servletRequest,
                                     HttpServletResponse servletResponse) {
            FileActionForm fileActionForm 
    = (FileActionForm) actionForm;
            FormFile file 
    = fileActionForm.getFile();
            
    try {
               InputStream in 
    = file.getInputStream();
               OutputStream out 
    = new FileOutputStream("d:\\"+new String(file.getFileName().getBytes("utf-8")));
               
    int i=0;
               
    byte[] buffer = new byte[4096];
               
    while((i = in.read(buffer,0,4096))!=-1){
               out.write(buffer,
    0,i);
               }
               in.close();
               out.close();
            } 
    catch (FileNotFoundException ex) {
            } 
    catch (IOException ex) {}
            
    try {
                servletRequest.setAttribute(
    "name",new String(file.getFileName().getBytes("UTF-8"),"UTF-8"));
            } 
    catch (UnsupportedEncodingException ex1) {
            }
            servletRequest.setAttribute(
    "size",Integer.toString(file.getFileSize()));
            
    return actionMapping.getInputForward();
        }
    }

    <bean:page>
      檢索JSP隱含對象,如request,session,response
    <bean:page id="this_session" property="session"/>
    <bean:write name="this_session" property="id"/>  //在頁面顯示session id號

    <bean:message>
     
    顯示ResourceBundle中的消息
      顯示邦定的、帶變量的資源文件:
    資源文件MyMessage.properties
    hello 
    = Hello,{0}

    struts
    -config.xml
      
    <message-resources parameter="MyMessage" key="my" />

    標簽
    <bean:message bundle="my" key="hello" arg0="Dada"/>
    頁面顯示結(jié)果:Hello,Dada

    <bean:resource>
    檢索Web資源的內(nèi)容,裝載到一個JAVABEAN中。
    屬性:id   定義一個代表web資源的變量
                 name  web資源的路徑
                 input 如果沒設(shè)置則 id 定義的變量為字符型,如果設(shè)置則id 定義的變量為java.io.InputStrean
    <bean:resource id="scource" name="/file.jsp" />  //file.jsp中的內(nèi)容裝載到一個變量中,scource就是這個變量的引用
    <bean:write name="scource"/> //寫出這個對象的內(nèi)容

    <bean:write>
       format屬性格式化輸出
        輸出Float型值 
        如request.setAtrribute("floatvalue",Float.valueOf("3.14159"));
       <bean:write format="#.####" name="floatvalue">  輸出結(jié)果是 3.1416

         輸出日期型
         request.setAtrribute("date",Calendar.getInstance());
        <bean:write format="MM-dd-yyyy hh:mm:ss" name="date" property="time"/> 輸出結(jié)果是 06-15-2006 10:12:35
      
        filter屬性
        默認為true,把輸出內(nèi)容中的特殊html符號作為普通字符串來顯示,如果為false,則不會
    posted on 2006-03-28 14:03 Derek.Guo 閱讀(1472) 評論(0)  編輯  收藏 所屬分類: Java
    MSN:envoydada@hotmail.com QQ:34935442
    主站蜘蛛池模板: 波多野结衣中文一区二区免费| 亚洲精品视频久久| 亚洲一级片在线观看| 亚欧日韩毛片在线看免费网站| 国产亚洲精品不卡在线| 深夜久久AAAAA级毛片免费看| mm1313亚洲精品国产| 国产亚洲成在线播放va| 亚洲成AⅤ人影院在线观看| 免费看黄福利app导航看一下黄色录像 | 国产免费一区二区三区在线观看| 亚洲国产a∨无码中文777| 日韩精品无码免费专区网站| 亚洲国产成人精品无码区在线观看| 成在人线av无码免费高潮喷水| 亚洲精品字幕在线观看| 久久免费观看国产99精品| 亚洲AV区无码字幕中文色| 亚洲欧洲免费视频| 精品久久亚洲中文无码| 午夜视频免费观看| 黄色视频在线免费观看| 国产成A人亚洲精V品无码| 59pao成国产成视频永久免费| 亚洲欧洲日本在线观看| 免费A级毛片无码A| a视频在线观看免费| 亚洲国产精品日韩在线观看| 破了亲妺妺的处免费视频国产| 永久免费精品影视网站| 4444亚洲国产成人精品| 韩国18福利视频免费观看| 一区二区在线免费视频| 亚洲色偷偷av男人的天堂| 美女被免费视频网站a国产| 一级毛片免费一级直接观看| 亚洲AV电影院在线观看| 青青青青青青久久久免费观看| 国产一区二区三区免费观在线| 亚洲一区中文字幕在线电影网 | 国产麻豆成人传媒免费观看|