日期:2014-05-17 浏览次数:20880 次
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>testStruts2</display-name> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:beans.xml</param-value> </context-param> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <description>DWR controller servlet</description> <servlet-name>DWR controller servlet</servlet-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>classes</param-name> <param-value> serviceImple.UserManagerImple </param-value> </init-param> <init-param> <param-name>crossDomainSessionSecurity</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>allowScriptTagRemoting</param-name> <param-value>true</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>DWR controller servlet</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> </web-app>
package serviceImple; import javax.annotation.Resource; import org.directwebremoting.annotations.DataTransferObject; import org.directwebremoting.annotations.Param; import org.directwebremoting.annotations.RemoteMethod; import org.directwebremoting.annotations.RemoteProperty; import org.directwebremoting.annotations.RemoteProxy; import org.directwebremoting.spring.SpringCreator; import org.springframework.stereotype.Component; import dao.UserDao; import model.User; import service.UserManager; @Component(value="userManageImple") @RemoteProxy(creator =SpringCreator.class, creatorParams = @Param(name = "beanName", value = "userManageImple"), name="userManageImple") public class UserManagerImple implements UserManager{ private UserDao userDao; @Override public void add(User user) { // TODO Auto-generated method stub userDao.save(user); } @Resource(name="userDaoImple") public void setU