package InterCeptor;


import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.apache.commons.fileupload.disk.DiskFileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.struts2.components.FieldError;

import sun.reflect.FieldInfo;

import check.CheckRegister;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.util.ValueStack;

import com.sun.jndi.url.iiopname.iiopnameURLContextFactory;
import com.sun.org.apache.bcel.internal.generic.NEW;

 


public class MyInterceptor implements Interceptor {

public void destroy() {
DiskFileItemFactory factory=new DiskFileItemFactory();

}

public void init() {


}

public String intercept(ActionInvocation invocation) throws Exception {
System.out.println("befor");
Map map=invocation.getInvocationContext().getParameters();
ValueStack stack=invocation.getInvocationContext().getValueStack();
System.out.println(stack.findString("username"));
Set set= map.entrySet();
Iterator iterator=set.iterator();
while(iterator.hasNext())
{

Entry entry= (Entry) iterator.next();
System.out.println(entry.getKey());
Object vObject=entry.getValue();
if(vObject instanceof String[])
{
String[] vStrings=(String[])vObject;
for(int i=0;i<vStrings.length;i++)
{
vStrings[i]=vStrings[i].trim();
System.out.println("长度="+vStrings.length);
System.out.println("vstring="+vStrings[i]);

}
}
//System.out.println(entry.getValue());
// System.out.println(invocation.getInvocationContext().getValueStack());

}
//String userString=(String) map.get("username");

//System.out.println("username+="+userString);
String temp=invocation.getInvocationContext().getName();
/*Class<CheckRegister> cg=(Class<CheckRegister>) Class.forName(temp);
java.lang.reflect.Field []field=cg.getFields();
for(int i=0;i<field.length;i++)
{
System.out.println("field="+field[i].getName());
}*/

String result=invocation.invoke();
System.out.println("result="+result);

System.out.println("after");
//System.out.println("username+="+userString);
System.out.println(temp+"=temp");
return result;
}


}

通过判断类型可知是string数组类型而不是单纯的string类型