如何在jsp中获取java控制台输出 [英] How can get java console output to view in jsp
问题描述
我在javaclass.how的excel文件中使用forloop获取getnumbersheets我可以在jsp中显示所有工作表的radiobutton的工作表名
我尝试过:
package com;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExcelDataParser
{
private ArrayList< string> arr;
public ArrayList< string> getArr(){
return arr;
}
public void setArr(ArrayList< string> arr) {
this.arr = arr;
}
// public static void getSheetNames()
public static void main(String args [])抛出IOException
{
ArrayList< string> arr = new ArrayList< string>();
try {
String str =C:\\Downloads\\\ \\ _Associate_Details.xlsx;
FileInputStream fileInputStream = null;
fileInputStream = new FileInputStream(str) ;
XSSFWorkbook工作簿=新的XSSFWorkbook(fileInputStream);
字符串工作;
for(int i = 0; i< workbook.getNumberOfSheets (); i ++)
{
work = workbook.getSheetName(i);
arr.add (工作);
}
System.out.println(arr);
workbook.close();
} catch(IOException e){
// TODO自动生成的捕获块
e.printStackTrace();
}}
}
为了在jsp页面中显示输出,你必须使用out.write( ); method.so,在for循环中使用
out.write(< input type =radio>+ work +< br>);
am using forloop for getnumbersheets in excel file in javaclass.how can i display sheetnames in jsp with radiobutton for all sheets
What I have tried:
package com;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExcelDataParser
{
private ArrayList<string>arr;
public ArrayList<string> getArr() {
return arr;
}
public void setArr(ArrayList<string> arr) {
this.arr = arr;
}
//public static void getSheetNames()
public static void main(String args[]) throws IOException
{
ArrayList<string> arr=new ArrayList<string>();
try {
String str="C:\\Downloads\\Associate_Details.xlsx";
FileInputStream fileInputStream = null;
fileInputStream = new FileInputStream(str);
XSSFWorkbook workbook = new XSSFWorkbook(fileInputStream);
String work;
for (int i = 0; i < workbook.getNumberOfSheets(); i++)
{
work=workbook.getSheetName(i);
arr.add(work);
}
System.out.println(arr);
workbook.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}
}
In order to show the output in jsp page you have to use out.write(); method.so, inside your for loop use
out.write("<input type="radio">"+work+"<br>");
这篇关于如何在jsp中获取java控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!