filetag.java

来自「簡單的多個實例的tag技術,剛入門不久的程序員,多多關照」· Java 代码 · 共 24 行

JAVA
24
字号
package com.jspdev.ch14;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.*;

public class FileTag extends SimpleTagSupport {
    private String fileName;
    public void setFileName(String fileName)
    {
    	this.fileName=fileName;
    }
    public void doTag() throws JspException, IOException
    {
    	BufferedReader in=new BufferedReader(new FileReader(fileName));
    	String temp="";
    	String fileContent="";
    	while((temp=in.readLine())!=null)
    	fileContent+=temp;
    	in.close();
	    getJspContext().getOut().write( "<table border=1><tr bgcolor=9944cc><td>文件标签</tr></td><tr bgcolor=cc44cc><td>"+fileContent+"</td></tr></table>" );
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?