Mitool

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

          2010年11月20日

          編輯web.xml文件時(shí),

          <?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><!-- 這一行出現(xiàn)紅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> 移動(dòng)到最后即可.

          附圖:





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

          2010年11月14日

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

          1. Dictionary OSGi Service 模板
          按照Eclipse向?qū)伞W⒁釫xport相應(yīng)包。

          2. Custom 端使用
          新建插件工程,Import字典服務(wù)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 插件。

          結(jié)果:


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

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

          主站蜘蛛池模板: 辽中县| 鲁甸县| 呼图壁县| 新闻| 楚雄市| 曲阜市| 额尔古纳市| 滨海县| 桐梓县| 游戏| 北票市| 安多县| 元朗区| 化德县| 神农架林区| 柳林县| 余姚市| 洞头县| 肥乡县| 嘉荫县| 五峰| 平利县| 凤凰县| 怀集县| 缙云县| 鸡泽县| 兴宁市| 九台市| 加查县| 兖州市| 宁津县| 马尔康县| 济南市| 河北区| 揭阳市| 渭源县| 香河县| 商城县| 湖南省| 治多县| 正定县|