I believe that many people will build a project that inherits fromThe system. Web. UI. Page class adds a lot of public partsCodePut it into it, such as permission detection and error handling (convenient). However, when constructing such a class, there is a problem that requires special attention, that is, the attribute definition of the class, let's take a look at the following attributes:
Public Hashtable extends tsecuritychecker
{
Set
{
Application ["AA"]=Value;
}
Get
{
If (Application ["AA"] = Null )
{< br>
application [" AA "] = New hashtable ();
}
Try
{< br> return (hashtable) application [" AA "];
}
Catch
{
Application ["AA"] = New Hashtable ();
Return (Hashtable) application ["AA"];
}
}
}
At first glance, it seems that there is no problem. Even the error handling is completed, and the compilation can also be successful. However, the basic page class is an interface class. What is the problem? After the interface class is inherited, its attributes will be initialized by the quilt class. When our subclass inherits this class, its own
WebThe editing interface cannot be opened again (depressed~), So if you want to use a similar function, you can modify it like this.
Private Hashtable _ javastsecuritychecker = Null ;
Public Hashtable geteffectchecker ()
{
If (Application ["AA"] = Null )
{
Application ["AA"]= NewHashtable ();
}
Try
{
Return(Hashtable) application ["AA"];
}
Catch
{
Application ["AA"]= NewHashtable ();
Return(Hashtable) application ["AA"];
}
}
All subclasses passGeteffectchecker ()Method, because the method does not affect interface initializationWebThe interface can still be edited normally.
One thing to emphasize is that the first approach will not affectProgram.