Mitool

          [//TODO]
          posts - 1, comments - 1, trackbacks - 0, articles - 1

          2010年11月14日

          編輯web.xml文件時,

          <?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_2_5.xsd"
              id
          ="WebApp_ID" version="2.5">
              
              
          <display-name>address</display-name>
              
          <servlet>
                  
          <servlet-name>address</servlet-name>
                  
          <servlet-class>address.servlet.AddressServlet</servlet-class>
                  
          <load-on-startup>0</load-on-startup>
                  
          <init-param><!-- 這一行出現紅xx提示-->
                      
          <param-name>ref1</param-name>
                      
          <param-value>value</param-value>
                  
          </init-param>
                  
          <init-param>
                      
          <param-name>ref2</param-name>
                      
          <param-value>value2</param-value>
                  
          </init-param>
              
          </servlet>

              
          <servlet-mapping>
                  
          <servlet-name>address</servlet-name>
                  
          <url-pattern>/*</url-pattern>
              
          </servlet-mapping>
          </web-app>


          提示以下信息:

          cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-
          param'. One of '{"http://java.sun.com/xml/ns/j2ee":run-as, "http://java.sun.com/
          xml/ns/j2ee":security-role-ref}' is expected.

          可把 <load-on-startup>0</load-on-startup> 移動到最后即可.

          附圖:





          posted @ 2010-11-20 11:23 Mitool 閱讀(907) | 評論 (1)編輯 收藏

          Eclispe 插件工程中提供了Dictionary OSGi Service 模板,寫了一下Custom端使用的代碼。

          1. Dictionary OSGi Service 模板
          按照Eclipse向導生成。注意Export相應包。

          2. Custom 端使用
          新建插件工程,Import字典服務Exprot的包。

          代碼片段:
          package demo.dictionary.custom;

          import org.osgi.framework.BundleActivator;
          import org.osgi.framework.BundleContext;
          import org.osgi.framework.ServiceReference;

          import demo.dictionary.DictionaryService;

          public class Activator implements BundleActivator {
              ServiceReference serviceReference 
          = null;

              
          public void start(BundleContext context) throws Exception {
                  serviceReference 
          = context.getServiceReference(DictionaryService.class.getName());
                  
                  
          if(null != serviceReference){
                      DictionaryService dictionaryService 
          = (DictionaryService)context.getService(serviceReference);
                     

                      System.out.println("check word:" + dictionaryService.check("word"));
                      System.out.println(
          "check osgi:" + dictionaryService.check("osgi"));
                      System.out.println(
          "check equinox:" + dictionaryService.check("equinox"));
                      System.out.println(
          "check eclipse:" + dictionaryService.check("eclipse"));
                  }
              }

              
          public void stop(BundleContext context) throws Exception {
                  serviceReference 
          = null;
              }
          }


          3. Custom 端使用
          如果沒輸出顯示,可在console中 update custom 插件。

          結果:


          4.工程文件下載
          demo.dictionary.custom.rar

          posted @ 2010-11-14 13:02 Mitool 閱讀(572) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 麟游县| 东莞市| 庆城县| 上杭县| 敖汉旗| 安多县| 齐齐哈尔市| 呼伦贝尔市| 青川县| 喀喇沁旗| 浠水县| 南岸区| 雷波县| 筠连县| 长宁县| 嘉祥县| 咸丰县| 景洪市| 抚宁县| 广平县| 托里县| 尉犁县| 冀州市| 江孜县| 米易县| 多伦县| 曲沃县| 台东市| 武汉市| 邯郸县| 航空| 余干县| 水富县| 海伦市| 建平县| 常德市| 邯郸市| 依兰县| 辽宁省| 万州区| 衡东县|