亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

openfire插件 servlet開發(fā)

系統(tǒng) 1744 0

1、首先建一個SampleServlet類,(名字隨意。)繼承 HttpServlet

?

      package com.maojd.test;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SampleServlet extends HttpServlet{

    private static final long serialVersionUID = -5404916983906926869L;
	 
   /* @Override
    public void init() throws ServletException {
        super.init();
    }*/
    
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       // super.doGet(request, response);
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        System.out.println("請求SampleServlet GET Method mao");
        out.print("請求SampleServlet GET Method mao");
        out.flush();
    }
 
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //super.doPost(request, response);
        this.doGet(request, response);
        
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        System.out.println("請求SampleServlet GET Method mao");
        out.print("請求SampleServlet POST Method mao");
        out.flush();
    }
 
}

    

?

?

2、配置servlet的路徑

? ? a) Web目錄下建 WEB-INF

? ? b)WEB-INF下建一個 web-custom.xml文件,配置對應(yīng)servlet映射信息。這個文件相當(dāng)于普通web工程的web.xml

openfire插件 servlet開發(fā)

?

web-custom.xml內(nèi)容如下:

?

      <?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <!-- Servlets -->
    <servlet>
        <servlet-name>SampleServlet</servlet-name>
        <servlet-class>com.maojd.test.SampleServlet</servlet-class>
    </servlet>

    <!-- Servlet mappings -->
    <servlet-mapping>
        <servlet-name>SampleServlet</servlet-name>
        <url-pattern>/servlet</url-pattern>
    </servlet-mapping>

</web-app>

    

?

?

說明:( 重要!!!!!!

Servlet的配置 url必須全部小寫。有一個大寫字母則找不到 對象的servlet

配置多個servlet,和單個方法一樣。配置多個servlet 和 servlet-mapping即可。

?

3、在plugin.xml文件中配置JSP頁面顯示位置

      <adminconsole>   
	<tab id="tab-server">
          <sidebar id="sidebar-server-settings">
              <item id="sample-service" name="Sample Service maojd" url="myplugin-demo1.jsp" description="Click is trigger sample plugin" />
          </sidebar>
    </tab>
</adminconsole>

    

備注:item標(biāo)簽中的id是自己定義的,要保證唯一,不能與其他的插件沖突,因此我們可以將這個ID的命名規(guī)則設(shè)為( 插件名-頁面 ) 。JSP頁面會根據(jù)這個ID來確定左側(cè)菜單欄的顯示位置。

?

4、創(chuàng)建JSP頁面

Web目錄下建jsp頁面 myplugin-demo1.jsp, 命名規(guī)范: 插件名-頁面名.jsp

openfire插件 servlet開發(fā)

?

      <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>hello world: 你好openfire</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="pageID" content="sample-service"/>
  </head>
  
  <body>
    <h3>hello world jsp!! <a href="/plugins/myplugin/servlet">SampleServlet</a></h3>
    <div class="jive-contentBoxHeader">jive-contentBoxHeader</div>
    <div class="jive-contentBox">jive-contentBox</div>
    
    <div class="jive-table">
        <table cellpadding="0" cellspacing="0" border="0" width="100%">
            <thead>
                <tr>
                    <th>&nbsp;sss</th>
                    <th nowrap>a</th>
                    <th nowrap>b</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td align="center">asdf</td>
                    <td align="center">asdf</td>
                    <td align="center">asdf</td>
                </tr>
                <tr class="jive-even">
                       <td align="center">asdf</td>
                    <td align="center">asdf</td>
                    <td align="center">asdf</td>
                </tr>
                <tr class="jive-odd">
                       <td align="center">asdf</td>
                    <td align="center">asdf</td>
                    <td align="center">asdf</td>
                </tr>
             </tbody>
        </table>
    </div>
  </body>
</html>

    

備注:Jsp需要注意:<meta name="pageID" content="sample-service"/>

PageID固定就這樣不變, Sample-service可以隨便,但是一定要和標(biāo)題對應(yīng)ID保持一致(top 導(dǎo)航id和左側(cè)導(dǎo)航id對應(yīng)), 一般是 plugin.xml 對應(yīng)

? openfire插件 servlet開發(fā)

?

?

openfire插件 servlet開發(fā)


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 亚洲人和日本人hd | 中国大陆一级毛片 免费 | 4399一级成人毛片 | 国产精品免费一区二区三区 | 9i9精品国产免费久久 | 老司机永久免费网站在线观看 | 久久精品中文字幕极品 | 成人免费黄网站 | 久久青青草原精品影院 | 九九热精品视频在线 | 一区二区三区欧美视频 | 日韩欧美成末人一区二区三区 | 国产成人综合亚洲欧美在 | 亚洲国产成人在线视频 | 九九热在线精品 | 一区二区三区欧美视频 | 婷婷综合 在线 | 亚洲国产精品久久久久 | 婷婷99精品国产97久久综合 | 三级不卡| 成人 亚洲 | 尹人香蕉网在线观看视频 | 青青青青青青久久久免费观看 | 伊人国产在线播放 | 亚洲国产激情在线一区 | 亚洲欧美天堂网 | 欧美中文字幕一区 | 亚洲精品国产一区二区图片欧美 | 亚洲综合图片网 | 国产你懂的 | 天天狠狠弄夜夜狠狠躁·太爽了 | 国产高清天干天天视频 | 久久国产成人精品麻豆 | 日本一级α一片免费视频 | 久久综合中文字幕一区二区 | 久久99热只有频精品6不卡 | 5060网午夜一级毛片在线看 | 青青青视频精品中文字幕 | 亚洲毛片免费观看 | 亚洲日本一区二区三区 | 在线观看欧美亚洲日本专区 |