<delect id="sj01t"></delect>
  1. <em id="sj01t"><label id="sj01t"></label></em>
  2. <div id="sj01t"></div>
    1. <em id="sj01t"></em>

            <div id="sj01t"></div>

            集成spring與Web容器教程

            時間:2024-10-21 00:20:25 J2EE培訓 我要投稿
            • 相關推薦

            集成spring與Web容器教程

              spring框架的主要優勢之一就是其分層架構,分層架構允許使用者選擇使用哪一個組件,同時為 J2EE 應用程序開發提供集成的框架。下面yjbys小編為大家準備了關于集成spring與Web容器教程,歡迎閱讀。

              1.創建HelloWorld 接口類

              package com.googlecode.garbagecan.cxfstudy.helloworld;

              import javax.jws.WebMethod;

              import javax.jws.WebParam;

              import javax.jws.WebResult;

              import javax.jws.WebService;

              @WebService

              public interface HelloWorld {

              @WebMethod

              @WebResult String sayHi(@WebParam String text);

              }

              2.創建HelloWorld實現類

              package com.googlecode.garbagecan.cxfstudy.helloworld;

              public class HelloWorldImpl implements HelloWorld {

              public String sayHi(String name) {

              String msg = "Hello " + name + "!";

              return msg;

              }

              }

              3.修改web.xml文件

              "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

              "http://java.sun.com/dtd/web-app_2_3.dtd" >

              cxfstudy

              cxf

              org.apache.cxf.transport.servlet.CXFServlet

              1

              cxf

              /ws/*

              org.springframework.web.context.ContextLoaderListener

              contextConfigLocation

              classpath*:**/spring.xml

              4.創建spring配置文件并放在classpath路徑下

              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"

              xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

              http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

              5.創建測試類

              package com.googlecode.garbagecan.cxfstudy.helloworld;

              import org.springframework.context.ApplicationContext;

              import org.springframework.context.support.ClassPathXmlApplicationContext;

              public class SpringClient {

              public static void main(String[] args) {

              ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");

              HelloWorld helloworld = (HelloWorld)context.getBean("helloworldClient");

              System.out.println(helloworld.sayHi("kongxx"));

              }

              }

              6.測試

              6.1 首先啟動tomcat或者使用maven的jetty,并訪問http://localhost:9000/ws/HelloWorld?wsdl來驗證web service已經啟動并且生效;

              6.2 然后運行測試類來驗證web service。

            【集成spring與Web容器教程】相關文章:

            Web開發的教程圖解03-30

            WEB教程標準應用標簽03-30

            Web Workers加速移動Web應用03-30

            電容器有哪些分類-電容器的分類03-29

            Spring如何實現郵件發送03-21

            調酒教程03-08

            web瀏覽創作效果精選03-29

            Web 2.0技術的內容03-30

            不同茶類的容器是哪些03-05

            <delect id="sj01t"></delect>
            1. <em id="sj01t"><label id="sj01t"></label></em>
            2. <div id="sj01t"></div>
              1. <em id="sj01t"></em>

                      <div id="sj01t"></div>
                      黄色视频在线观看