<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      DWR+SpringMVC整合的3種方式之一

      早上寫了一篇dwr的基礎(chǔ)文章,下午看了孔浩老師的dwr與springmvc的整合視頻,自己跟著動(dòng)手把各種方式都練習(xí)了一下,遇到些問題,記錄給自己以后用dwr的時(shí)候復(fù)制吧。


      方式一:各干各的,耦合度低


      說明:方式一遇到的問題最少,可以說是順利通過。

      1、pom.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
      
          <groupId>com.lessony</groupId>
          <artifactId>dwr-spring01</artifactId>
          <version>1.0-SNAPSHOT</version>
          <packaging>war</packaging>
      
          <name>dwr-spring01</name>
      
          <properties>
              <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
              <spring.version>4.0.3.RELEASE</spring.version>
          </properties>
        
          <dependencies>
              <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>4.10</version>
                  <scope>test</scope>
              </dependency>
              
              <!--spring的依賴-->
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-context</artifactId>
                  <version>${spring.version}</version>
              </dependency>
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-core</artifactId>
                  <version>${spring.version}</version>
              </dependency>
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-beans</artifactId>
                  <version>${spring.version}</version>
              </dependency>
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-webmvc</artifactId>
                  <version>${spring.version}</version>
              </dependency>
              
              <!--dwr的依賴-->
              <dependency>
                  <groupId>org.directwebremoting</groupId>
                  <artifactId>dwr</artifactId>
                  <version>3.0.M1</version>
              </dependency>
          </dependencies>
      
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <version>3.1</version>
                      <configuration>
                          <source>1.7</source>
                          <target>1.7</target>
                          <compilerArguments>
                              <!-- endorseddirs<目錄>覆蓋簽名的標(biāo)準(zhǔn)路徑的位置 -->
                              <endorseddirs>${endorsed.dir}</endorseddirs>
                          </compilerArguments>
                      </configuration>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-war-plugin</artifactId>
                      <version>2.3</version>
                      <configuration>
                          <failOnMissingWebXml>false</failOnMissingWebXml>
                      </configuration>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-dependency-plugin</artifactId>
                      <version>2.6</version>
                      <executions>
                          <execution>
                              <phase>validate</phase>
                              <goals>
                                  <goal>copy</goal>
                              </goals>
                              <configuration>
                                  <outputDirectory>${endorsed.dir}</outputDirectory>
                                  <silent>true</silent>
                                  <artifactItems>
                                      <artifactItem>
                                          <groupId>javax</groupId>
                                          <artifactId>javaee-endorsed-api</artifactId>
                                          <version>7.0</version>
                                          <type>jar</type>
                                      </artifactItem>
                                  </artifactItems>
                              </configuration>
                          </execution>
                      </executions>
                  </plugin>
                  
                  <!--jetty服務(wù)器-->
                  <plugin>
                      <groupId>org.mortbay.jetty</groupId>
                      <artifactId>jetty-maven-plugin</artifactId>
                      <version>8.1.16.v20140903</version>
                      <configuration>
                          <scanIntervalSeconds>10</scanIntervalSeconds>
                          <webApp>
                              <contextPath>/dwr-spring01</contextPath>
                          </webApp>
                          <connectors>
                              <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                                  <port>8801</port>
                                  <maxIdleTime>60000</maxIdleTime>
                              </connector>
                          </connectors>
                      </configuration>
                  </plugin>
                  
                  <!--打包插件,把web打成zip包-->
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-assembly-plugin</artifactId>
                      <version>2.4</version>
                      <configuration>
                          <descriptors>
                              <descriptor>assembly.xml</descriptor>
                          </descriptors>
                      </configuration>
                      <executions>
                          <!-- 當(dāng)執(zhí)行mvn package時(shí)才會(huì)打包 -->
                          <execution>
                              <id>make-assembly</id>
                              <phase>package</phase>
                              <goals>
                                  <goal>single</goal>
                              </goals>
                          </execution>
                      </executions>
                  </plugin>
                  
              </plugins>
          </build>
      
      </project>
      


      2、web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
          <!-- 創(chuàng)建Spring的監(jiān)聽器 -->
          <listener>
              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
          </listener>
          <!-- Spring 的監(jiān)聽器可以通過這個(gè)上下文參數(shù)來獲取beans.xml的位置 -->
          <context-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>classpath*:beans.xml</param-value>
          </context-param>
      	
          <servlet>
              <servlet-name>dispatcher</servlet-name>
              <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          </servlet>
          <servlet-mapping>
              <servlet-name>dispatcher</servlet-name>
              <url-pattern>/</url-pattern>
          </servlet-mapping>
          <filter>
              <filter-name>characterFilter</filter-name>
              <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
              <init-param>
                  <param-name>encoding</param-name>
                  <param-value>UTF-8</param-value>
              </init-param>
          </filter>
          <filter-mapping>
              <filter-name>characterFilter</filter-name>
              <url-pattern>/*</url-pattern>
          </filter-mapping>
      	
          <servlet>
              <servlet-name>dwr-invoker</servlet-name>
              <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
              <load-on-startup>1</load-on-startup>
          </servlet>
         
          <servlet-mapping>
              <servlet-name>dwr-invoker</servlet-name>
              <url-pattern>/dwr/*</url-pattern>
          </servlet-mapping>
      </web-app>
      

      3、java類

      package com.lessony.dwr.spring01.service;
      
      public interface IHelloService {
      	public String sayHello(String name);
      }
      


      package com.lessony.dwr.spring01.service.impl;
      
      import com.lessony.dwr.spring01.service.IHelloService;
      import org.springframework.stereotype.Service;
      
      @Service("helloService")
      public class HelloService implements IHelloService {
      
          @Override
          public String sayHello(String name) {
              System.out.println("hello " + name);
              return "hello: "+name;
          }
      
      }
      

      4、配置dwr,中dwr-servlet.xml中配置

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xmlns:context="http://www.springframework.org/schema/context"
      	xmlns:mvc="http://www.springframework.org/schema/mvc"
      	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                  http://www.springframework.org/schema/beans/spring-beans.xsd
                  http://www.springframework.org/schema/context 
                  http://www.springframework.org/schema/context/spring-context-4.0.xsd
                  http://www.springframework.org/schema/mvc 
                  http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
      	
      	<mvc:annotation-driven/>
      	<mvc:resources location="/resources/" mapping="/resources/**"/>
      	<context:component-scan base-package="com.lessony.dwr.spring01.controller"/>
      	
      	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      		<property name="prefix" value="/WEB-INF/jsp/"/>
      		<property name="suffix" value=".jsp"/>
      	</bean>
      	
      	<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
      		<property name="exceptionMappings">
      			<props>
      				<prop key="com.lessony.dwr.spring01.model.MyException">error</prop>
      			</props>
      		</property>
      	</bean>
      	
      </beans>
      

      還有一個(gè)spring的beans.xml文件

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:p="http://www.springframework.org/schema/p"
             xmlns:aop="http://www.springframework.org/schema/aop"
             xmlns:context="http://www.springframework.org/schema/context"
             xmlns:tx="http://www.springframework.org/schema/tx"
             xsi:schemaLocation="http://www.springframework.org/schema/beans 
              http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
              http://www.springframework.org/schema/aop 
              http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
              http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context-4.0.xsd
              http://www.springframework.org/schema/tx 
              http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
       
      	<!-- 打開Spring的Annotation支持 -->
      	<context:annotation-config />
      	<!-- 設(shè)定Spring 去哪些包中找Annotation -->
      	<context:component-scan base-package="com.lessony.dwr.spring01" />
      
      </beans>

      5、jsp頁面

      <%@page contentType="text/html" pageEncoding="UTF-8"%>
      <!DOCTYPE html>
      <html>
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
              <title>JSP Page</title>
              <script src="<%=request.getContextPath()%>/dwr/engine.js"></script>
              <script src="<%=request.getContextPath()%>/dwr/interface/hello01.js"></script>
              
              <script>
                  hello01.sayHello("zhang三",function(data){
      		alert(data);
      	})
              </script>
          </head>
          <body>
              <h1>Hello World!</h1>
          </body>
      </html>

      全部編輯完成之后,右鍵項(xiàng)目,選擇Run As... 繼續(xù)選擇7 Maven build...  ,在彈出框的Goals中輸入jetty:run ,然后點(diǎn)擊RUN運(yùn)行。

      打開瀏覽器,輸入http://localhost:8801/dwr-spring01/dwr01.jsp,就可以看到控制臺(tái)輸出了:hello zhang三,而前臺(tái)彈出了:hello zhang三



      最后附上zip包,鏈接:http://download.csdn.net/detail/lxn39830435731415926/8714139

      最后抱怨一下,用netbeans真心卡啊,如果不是它有html5、js、jquery等提示和改善代碼質(zhì)量的建議性的編程提示,我根本不會(huì)用它。庫苦逼啊,打算以后不用了。


      posted @ 2015-05-17 23:01  Java夜未眠  閱讀(35)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 99精品国产在热久久婷婷| 大尺度国产一区二区视频 | 年日韩激情国产自偷亚洲| 国产黄色大片网站| 昭平县| 精品自拍偷拍一区二区三区| 一区二区三区国产偷拍| 久久久无码精品午夜| 摸丰满大乳奶水www免费| 少妇又爽又刺激视频| 插入中文字幕在线一区二区三区| 青青草无码免费一二三区| 国产成人精品亚洲精品密奴| 成av免费大片黄在线观看| 国产AV无码专区亚洲AWWW| 精品一区二区三区自拍图片区| 亚洲综合不卡一区二区三区| 中文字幕无线码免费人妻| 亚洲高清日韩专区精品| 伊人久久大香线蕉av五月天| 久久综合干| 精品无码人妻一区二区三区| 奶头又大又白喷奶水av| 国产一区二区三区不卡视频| 中文字幕有码日韩精品| 亚洲A综合一区二区三区| 亚洲自拍偷拍一区二区三区| 无码人妻精品一区二| 超清无码一区二区三区| 欧美乱大交xxxxx疯狂俱乐部| 国产一二三五区不在卡| 91亚洲国产三上悠亚在线播放 | 果冻传媒色av国产在线播放| 国产精品激情av在线播放| 欧美激情一区二区三区成人 | 亚洲av片在线免费观看| 亚洲色一区二区三区四区| 极品人妻videosss人妻| 日本黄韩国色三级三级三| 国产jlzzjlzz视频免费看| 五月婷婷激情视频俺也去淫|