MENU

[泛微EC9] 记泛微如何简单写restful接口?

• 2024 年 07 月 08 日 • 阅读: 525 • 泛微OA

目录:\src\com\api\formmode\web\CustomWanziTestFormmodeAction.java
编译为class后\src\com\api\formmode\web\CustomWanziTestFormmodeAction.class
(需重启服务器)
请求地址:/api/formmode/custom/wanzitestaction/test?param1=111
返回内容:

{
    "message": "This is a test response from the custom wanzitestaction formmode action.",
    "param1": "111"
}
package com.api.formmode.web;

import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;

@Path("/formmode/custom/wanzitestaction")
public class CustomWanziTestFormmodeAction {
    public CustomWanziTestFormmodeAction() {
    }

    @POST
    @Path("/test")
    @Produces({"application/json"})
    public String testFormmode(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        response.setContentType("application/json; charset=utf-8");
        String param1 = request.getParameter("param1");
        JSONObject result = new JSONObject();
        result.put("param1", param1);
        result.put("message", "This is a test response from the custom wanzitestaction formmode action.");
        return result.toJSONString();
    }
}
返回文章列表 打赏
本页链接的二维码
打赏二维码
添加新评论

已有 2 条评论
  1. Ruiruier Ruiruier

    楼主 您好,您是用什么工具部署E9环境的开发得的能,能否出一个教程 感谢

    1. @Ruiruierhttps://e-cloudstore.com/doc.html?appId=c6a9ae6e47b74d4da04c935ed51d177a&maxImgWidth=800

      我是用的这个官方教程,你也可以从导航站 huahan.cc 看到相关内容。