建立实现逻辑控制类
//Action控制类:OgnlTypeConvertjava
package cneduhld;
import comopensymphonyxworkActionSupport;
public class OgnlTypeConvert extends ActionSupport
{
private User user ;
public User getUser()
{
return user;
}
public void setUser(User user)
{
thisuser = user;
}
public String execute()
{
if(thisgetUser()getUserName()equals(thtwin) &&
thisgetUser()getUserPass()equals(thtwinjee) )
{
return SUCCESS ;
}
else
{
return ERROR ;
}
}
}
实现类型转换的核心类
//类型转换核心类
package cneduhld;
import javautilMap;
import ognlDefaultTypeConverter;
public class TypeConversion extends DefaultTypeConverter
{
@Override
public Object convertValue(Map context Object values Class toClass)
{
if(toClass == Userclass)
{
String strUser[] = (String[])values ;
String userInfo[] = strUser[]split() ;
User user = new User() ;
usersetUserName(userInfo[]) ;
usersetUserPass(userInfo[]) ;
return user ;
}
[] [] [] []