Recently, ESET add my domain name to the black-list of their database. You can’t open my site and been warned my site is not safe if your PC is running the ESS or EAV. Why Eset block my site?The answer is obvious. That is reason that you come here. I promise that my site is pure, no virus, no spyware, no Trojan, no pop ads. You can test my word through intalling Kaspersky or other Antivirus Software. If you want open my site and take latest escalation ID & Activation Code, close your ESET software(disable antivirus and antispyware protection function temporarily) or by proxy or virtual machinor. You can also feed the RSS source http://feed.loserblog.cn.
Home > Programm > dwr+spring integration

dwr+spring integration

1, the application will be put dwr.jar / WEB-INF/lib directory
2, configure web.xml, add the following code:
Code
  

    1. <! – Initialization WebApplicationContext ->
    2. <context-param>
    3. <param-name> ContextConfigLocation </ param-name>
    4. <param-value> / WEB-INF/applicationContext.xml, / WEB-INF/action-servlet.xml </ param-value>
    5. </ Context-param>
    6. <listener>
    7. <listener-class>
    8. org.springframework.web.context.ContextLoaderListener
    9. </ Listener-class>
   10. </ Listener>
   11. <! – DWR configured interceptor ->
   12. <servlet>
   13. <servlet-name> Dwr-invoker </ servlet-name>
   14. <servlet-class> Uk.ltd.getahead.dwr.DWRServlet </ servlet-class>
   15. <init-param>
   16. <param-name> Debug </ param-name>
   17. <param-value> True </ param-value>
   18. </ Init-param>
   19. </ Servlet>
   20. <servlet-mapping>
   21. <servlet-name> Dwr-invoker </ servlet-name>
   22. <url-pattern> / Dwr / * </ url-pattern>
   23. </ Servlet-mapping>

  
3, by documents in the dwr.xml
The content of the document:
Code
  

    1. <? Xml version = "1.0" encoding = "UTF-8"?>
    2. <! DOCTYPE dwr PUBLIC "- / / GetAhead Limited / / DTD Direct Web Remoting 1.0 / / EN" "http://www.getahead.ltd.uk/dwr/dwr10.dtd">
    3. <dwr>
    4. <allow>
    5. <create Creator="spring" javascript="DWRUser">
    6. <param Name="beanName" value="DWRUser"/>
    7. </ Create>
    8. </ Allow>
    9. </ Dwr>

  
creator attribute's value may be new, struts, spring …… because to do here is to organize the spring, therefore, set to "spring", javascript = "DWRUser" said examples into javascript language named after DWRUser, Prospects pages can code (<script type = 'text / javascript' xsrc ='../../ dwr / interface / DWRUser.js'> </ script>) to call. param element of the name attribute value can be a class, beanName, here with beanName, value for value is defined in the applicationContext.xml in a bean value of the id.
4, to create an entity bean for the DWR into js
Code
  

    1. Package com.note.dwr;
    2. Import com.note.bussies.service.IUserService;
    3. Public class User (
    4. Private IUserService ius;
    5.
    6. Public IUserService getIus () (
    7. Return ius;
    8.)
    9. Public void setIus (IUserService ius) (
   10. This.ius = ius;
   11.)
   12. Public User () (
   13.
   14.)
   15. Public boolean isExist (String username) (
   16. Users user = this.ius.getUserByName (username);
   17. Return (null == user)? False: true;
   18.)
   19.)

  
5, in applicationContext.xml in the allocation of Step 4 to write the bean
Code
  

    1. ……
    2. <bean Id="DWRUser" class="com.note.dwr.User">
    3. <property Name="ius">
    4. <ref Bean="UserService" />
    5. </ Property>
    6. </ Bean>
    7. ……

  
6, in view of the page called
To import the following text of each document detailing the functions no longer here
Code
  

    1. <script Type='text/javascript' src='../../dwr/interface/DWRUser.js'> </ script>
    2. <script Type='text/javascript' src='../../dwr/engine.js'> </ script>
    3. <script Type='text/javascript' src='../../dwr/util.js'> </ script>

  
Because my view is on the document / view / user / under, so here to return to the root of the ../../
Specific call:
Code
  

    1. <script Type='text/javascript'>
    2. Function regUserChked () (
    3. Var username = $ ( "username"). Value;
    4. DWRUser.isExist (username, showData); / / showData callback function
    5.)
    6. Function showData (data) (
    7. If (data) (
    8. DWRUtil.setValue ( "userMsg", "the user name has been registered, please change your user name!");
    9.) Else (
   10. DWRUtil.setValue ( "userMsg", "Congratulations to you, the user name has not yet been registered!");
   11.)
   12.)
   13. </ Script>
   14. Input type = "text" name = "username" value = "" onblur = "regUserChked ()" /> <div id="userMsg"> </ div>

Categories: Programm Tags:
  1. No comments yet.
  1. No trackbacks yet.
  • Partner links