<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 第四章 第一個Web頁面 上一章運行入口類后,只是在IDE里打印出Hello world。這一章我們要實現在瀏覽器的頁面輸出Hello world. ### 修改入口類 再次打開入口類lightsword.java, * 新增一個方法hello ~~~ @RequestMapping("/hello") public String hello(){ return "Hello world"; } ~~~ * 在類上新增@RestController注解 lightsword.java完整代碼如下: ~~~ package lightsword; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @SpringBootApplication @RestController public class lightsword { public static void main(String[] args){ SpringApplication.run(lightsword.class, args); } @RequestMapping("/hello") public String hello(){ return "Hello world"; } } ~~~ ### 結果 再次運行,然后打開瀏覽器,訪問http://127.0.0.1:9527/hello (如果沒有配置9527端口的,參考上一章內容配置),結果在Web頁面輸出Hello world ### 講解 本例中多了兩個注解: 1. @RequestMapping 它起一個地址路由的作用,例子中配置的值為"/hello",我們訪問的地址就是主機(127.0.0.1:9527)加上(/hello),構成:http:127.0.0.1:9527/hello。 不難看出@RequestMapping對應的是我們的uri。 2. @RestController 要想通用訪問http:127.0.0.1:9527/hello,就可以請求我們的hello方法,就必須使用@RestController注解。它的作用就是將方法結果直接返回給調用者。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看