📄 showresult.jsp
字号:
<%@ page contentType="text/html;charset=gb2312" import="java.io.*,java.text.*" errorPage="err.jsp" %>
<%
DecimalFormat df = new DecimalFormat("0.00");
//File file=new File (config.getServletContext().getRealPath(".")+"/result01.txt");
File file=new File (config.getServletContext().getRealPath(".")+"/myweb/result01.txt");
FileInputStream fin=new FileInputStream(file);
BufferedReader in=new BufferedReader(new InputStreamReader(fin));
String result=in.readLine();
String choice[]={"支持","反对","无所谓"};
int num[]=new int[choice.length];
double total=0;
for (int i=0;i<choice.length;i++)
{
int begin=result.indexOf(choice[i]);
int end=result.lastIndexOf(choice[i]);
num[i]=Integer.parseInt(result.substring(begin+choice[i].length(),end));
total+=num[i];
}
fin.close();
in.close();
%>
<table bordercolor="#6D6D6D" border="1" width="100%">
<%
for (int i=0;i<choice.length;i++)
{
%>
<tr><td width="20%"><%= choice[i]%></td><td width="20%"><%= num[i]%></td><td width="500"><img src="picture/1.gif" height=6 width=<%=(int) (num[i]/total*500)%>><%= df.format((num[i]/total*100))+"%"%></td></tr>
<%
}
%>
</table>
<a href="index.jsp">返回</a>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -