<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Magician-WebMagician 的官方 Web 組件

          聯(lián)合創(chuàng)作 · 2023-09-23 19:43

          Magician-Web 是Magician的官方 web組件,可以很方便的管理Controller,支持?jǐn)r截器,會(huì)話管理,注解式參數(shù)校驗(yàn),實(shí)體類接收參數(shù)等

          文檔

          https://magician-io.com

          示例

          導(dǎo)入依賴

          <!-- This is the jar package build by this project -->
          <dependency>
              <groupId>com.github.yuyenews</groupId>
              <artifactId>Magician-Web</artifactId>
              <version>last version</version>
          </dependency>
          
          <!-- This is Magician -->
          <dependency>
              <groupId>com.github.yuyenews</groupId>
              <artifactId>Magician</artifactId>
              <version>last version</version>
          </dependency>
          
          <!-- This is the log package, which supports any package that can be bridged with slf4j -->
          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-jdk14</artifactId>
              <version>1.7.12</version>
          </dependency>

          創(chuàng)建核心handler

          @HttpHandler(path="/")
          public class DemoHandler implements HttpBaseHandler {
          
              @Override
              public void request(MagicianRequest magicianRequest, MagicianResponse response) {
                  try{
                      // 主要是這句
                      MagicianWeb.createWeb()
                              .request(magicianRequest);
                  } catch (Exception e){
                  }
              }
          }

          創(chuàng)建 Controller

          @Route("/demoController")
          public class DemoController {
          
          	// You can use entity classes to receive parameters
          	@Route(value = "/demo", requestMethod = ReqMethod.POST)
          	public DemoVO demo(DemoVO demoVO){
          		return demoVO;
          	}
          
          	// You can also directly use MagicianRequest to get parameters
          	@Route(value = "/demob", requestMethod = ReqMethod.POST)
          	public String demob(MagicianRequest request){
          		return "ok";
          	}
          
          	// Download file
          	@Route(value = "/demob", requestMethod = ReqMethod.POST)
          	public ResponseInputStream demob(){
          		ResponseInputStream responseInputStream = new ResponseInputStream();
          		responseInputStream.setName("file name");
          		responseInputStream.setBytes(file bytes);
          		return responseInputStream;
          	}
          }

          啟動(dòng) HTTP 服務(wù)

          Magician.createHttp()
                          .scan("handler和controller所在的包名")
                          .bind(8080);

           

          瀏覽 23
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  91五月丁香啪啪视频 | 视频精品一区二区三区 | 日韩一级性爱视频 | 国产精选久久久60086 | 黄色视频免费精品 |