<Init-param>
<Param-Name> debug </param-Name>
<Param-value> true </param-value>
</Init-param>
Resolution: <init-param>
Parameters in the servlet range can only be obtained in the servlet Init () method. The configuration in Web. XML is as follows:
<Servlet>
<Servlet-Name> mainservlet </servlet-Name>
<Servlet-class> com. Wes. Controller. mainservlet </servlet-class>
<Init-param>
<Param-Name> param1 </param-Name>
<Param-value> avalible in servlet Init () </param-value>
</Init-param>
<Load-on-startup> 0 </load-on-startup>
</Servlet>
In servlet, you can use the following code:
Package com. Wes. Controller;
IMPORT javax. servlet. servletexception;
IMPORT javax. servlet. http. httpservlet;
Public class mainservlet extends httpservlet ...{
Public mainservlet ()...{
Super ();
}
Public void Init () throws servletexception ...{
System. Out. println ("the following two parameters param1 are stored in servlet ");
System. Out. println (this. getinitparameter ("param1 "));
System. Out. println ("the following parameters are stored in servletcontext ");
System. Out. println (getservletcontext (). getinitparameter ("context/Param "));
}
}
Parameters can only be obtained through this. getinitparameter ("param1") in the servlet Init () method.
----------------------------------------------------------------------------
<URL-pattern>/DWR/* </url-pattern>
Resolution: It indicates that all files containing the WDR name when the project is started will be called here.
----------------------------------------------------------------------------
<Create javascript = "hello" creator = "new">
<Param name = "class" value = "com. Yinhe. Service. hellodwr"> </param>
Parse: javascript = "hello" Name the hellowdr class "hello" in JavaScript to call the data in the hellowdr class.
Creator = "new" is created in the form of new
----------------------------------------------------------------------------
<SCRIPT type ='Text/JavaScript'Src ='/DWR/engine. js'> </SCRIPT>
<SCRIPT type ='Text/JavaScript'Src ='/DWR/interface/Hello. js'> </SCRIPT>
<SCRIPT type ='Text/JavaScript'Src ='/DWR/util. js'> </SCRIPT>
Resolution: The three items are directly copied to the JSP file displayed on the successfully tested page.
----------------------------------------------------------------------------
Hello. gethello (username, callback );
The Hello. gethello parameter in JS has an additional callback parameter used to return data.
Note: prompts in JS to call the methods in the hellowdr class are not prompted by callback.
Write by yourself