⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filetag.java

📁 簡單的多個實例的tag技術,剛入門不久的程序員,多多關照
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -