返回字符串

package com.litongjava.tio.boot.hello.AController;

import com.litongjava.tio.http.server.annotation.RequestPath;
@AController
@RequestPath("/test/string")
public class TestStringController {

  @RequestPath()
  public String index() {
    return "index";
  }
}

这段代码定义了一个使用 tio-boot 框架的 HTTP 控制器,专门用于处理 /test/string 路径下的 Web 请求,并返回一个字符串。

  • @RequestPath(): 方法注解,指定了此方法处理的具体请求路径。结合类注解,当 HTTP 请求发送到 /test/string 时,此方法将被调用。
  • 方法不接收任何参数,这意味着它响应的是不需要任何输入的请求。
  • 方法返回一个字符串 "index"。在 tio-boot 框架中,会直接将字符串 "index" 作为响应内容发送给客户端不会查找名为 "index" 的视图模板,并用该模板生成 HTTP 响应。