1.导出文件时,360浏览器调用2次servlet,提交如下form如下:
<form id="downxmlform" name="downxmlform" action = "/exportKPIManager" method="post">
<input type="hidden" id="threshold" name="threshold" value="1"/>
<input type="hidden" id="kpiids" name="kpiids"/>
</form>
备注:网上输入“360浏览器调用2次servlet”查询了一下,都说是360浏览器问题。但是我在其他JSP页面也是这么提交又没出现这个问题。
2.模拟安全访问同一方法:
模拟多用户并发访问同一个方法的情况:
public class Test extends Thread{
private String str;
private static boolean isUsing = false;
private static int m = 0;
private int addcount=0;
public Test(String str,int addcount){
this.str = str;
this.addcount = addcount;
}
public static void main(String[] args) {
new Test("AAA",100).start();
new Test("BBB",200).start();
}
void test(String str,int count)
{
synchronized (this) {
if(isUsing == true)
{
System.out.println("test is using....");
return;
}
else
{
isUsing = true;
}
for(int i=0;i<count;i++)
{
m++;
System.out.println(str+":"+m);
}
isUsing = false;
}
}
@Override
public void run() {
test(str,addcount);
}
}
//模拟多用户并发访问同一个Servlet情况
public class Test2 extends Thread{
private String str;
private static boolean isUsing = false;