字符转变量
<%
class Init
{
public String strInput;
Init(String strInput)
{
this.strInput = strInput;
}
}
class StrToVal
{
Init newInit = new Init("11234");
String getClassField(String fieldname,Class classInt) throws Exception
{
if (classInt.getField(fieldname)!=null)
return classInt.getField(fieldname).get(newInit).toString();
throw new Exception(classInt.getName()+"No Such Field"+ fieldname);
}
public String strGet() throws Exception
{
return getClassField("strInput",Init.class);
}
}
/*
String mystr="1234";
String my="mystr";
StrToVal str1 = new StrToVal();
String temp;
str1.newInit.strInput=my;
temp=str1.strGet();
out.println(temp);
out.println("<br>");
**/
%>