亚洲一级免费看,特黄特色大片免费观看播放器,777毛片,久久久久国产一区二区三区四区,欧美三级一区二区,国产精品一区二区久久久久,人人澡人人草

J2EE培訓

集成spring與Web容器教程

時間:2024-10-06 06:02:06 J2EE培訓 我要投稿
  • 相關推薦

集成spring與Web容器教程

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

  1.創(chuàng)建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.創(chuàng)建HelloWorld實現(xiàn)類

  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.創(chuàng)建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.創(chuàng)建測試類

  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已經(jīng)啟動并且生效;

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

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

Web開發(fā)的教程圖解07-29

關于容器定位的CSS教程09-16

WEB教程標準應用標簽09-14

EXCEL集成工具箱詳細教程08-04

web標準與web標準的好處概況08-10

Web Workers加速移動Web應用07-11

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

大學英語作文:A Spring Morning10-27

web項目總結06-13

web項目總結10-20