• 大小: 82KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-09
  • 语言: 数据库
  • 标签: jersey  ssm+jersey2  

资源简介

spring4+springMVC+mybatis集成jersey2,一个实现了RESTful的webservice框架。源码中有sql脚本(MySQL)。

资源截图

代码片段和文件信息

package com.zjk.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONobject;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Map;

/**
 * @Author: 朱建柯
 * @Date: 2018/4/3 9:42
 * @Description:
 */
public class baseController {

    private static String serverUri = “http://127.0.0.1:8079“;
    public JSONobject requestResult(HttpServletRequest request Mapject> param) {
        ClientConfig config = new ClientConfig();
        config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION true);
        Client client = ClientBuilder.newClient(config);
        Response response = null;
        WebTarget target = null;
        switch (request.getMethod()) {
            case HttpMethod.GET:
                if (request.getQueryString() == null || request.getQueryString().equals(““)){
                    target = client.target(serverUri + request.getRequestURI());
                } else {
                    target = client.target(serverUri + request.getRequestURI() + “?“ + request.getQueryString());
                }
                response = target.request().get();
                break;
            case HttpMethod.POST:
                target = client.target(serverUri + request.getRequestURI());
                response = target.request().post(Entity.entity(param MediaType.APPLICATION_JSON));
                break;
            case HttpMethod.PUT:
                target = client.target(serverUri + request.getRequestURI());
                response = target.request().put(Entity.entity(param MediaType.APPLICATION_JSON));
                break;
            default:
                target = client.target(serverUri + request.getRequestURI() + “?“ + request.getQueryString());
                response = target.request().delete();
                break;
        }
        String eout = response.readEntity(String.class);
        response.close();
        return JSON.parseobject(eout);
    }

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        329  2018-04-02 17:50  zjkjerseydemo\.idea\artifacts\zjkjerseyclient_war.xml

     文件       9175  2018-04-03 10:11  zjkjerseydemo\.idea\artifacts\zjkjerseyclient_war_exploded.xml

     文件        307  2018-04-02 17:50  zjkjerseydemo\.idea\artifacts\zjkjerseydemo_war.xml

     文件        676  2018-04-02 17:50  zjkjerseydemo\.idea\artifacts\zjkjerseydemo_war_exploded.xml

     文件        329  2018-04-02 17:50  zjkjerseydemo\.idea\artifacts\zjkjerseymapper_war.xml

     文件       8843  2018-04-03 10:09  zjkjerseydemo\.idea\artifacts\zjkjerseymapper_war_exploded.xml

     文件        329  2018-04-02 17:50  zjkjerseydemo\.idea\artifacts\zjkjerseyserver_war.xml

     文件       9175  2018-04-03 10:09  zjkjerseydemo\.idea\artifacts\zjkjerseyserver_war_exploded.xml

     文件        333  2018-04-02 17:50  zjkjerseydemo\.idea\artifacts\zjkjerseyservice_war.xml

     文件        955  2018-04-02 17:53  zjkjerseydemo\.idea\artifacts\zjkjerseyservice_war_exploded.xml

     文件        993  2018-04-02 17:54  zjkjerseydemo\.idea\compiler.xml

     文件        545  2018-04-02 17:54  zjkjerseydemo\.idea\encodings.xml

     文件        605  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__commons_fileupload_commons_fileupload_1_3_2.xml

     文件        503  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__commons_io_commons_io_2_2.xml

     文件        525  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__commons_lang_commons_lang_2_5.xml

     文件        558  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__commons_logging_commons_logging_1_2.xml

     文件        486  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__com_alibaba_druid_1_1_2.xml

     文件        514  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__com_alibaba_fastjson_1_2_39.xml

     文件        644  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_9.xml

     文件        595  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_core_2_8_9.xml

     文件        623  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_databind_2_8_9.xml

     文件        641  2018-04-03 10:09  zjkjerseydemo\.idea\libraries\Maven__com_fasterxml_jackson_jaxrs_jackson_jaxrs_base_2_5_4.xml

     文件        704  2018-04-03 10:09  zjkjerseydemo\.idea\libraries\Maven__com_fasterxml_jackson_jaxrs_jackson_jaxrs_json_provider_2_5_4.xml

     文件        736  2018-04-03 10:09  zjkjerseydemo\.idea\libraries\Maven__com_fasterxml_jackson_module_jackson_module_jaxb_annotations_2_5_4.xml

     文件        597  2018-04-03 09:45  zjkjerseydemo\.idea\libraries\Maven__javax_annotation_javax_annotation_api_1_2.xml

     文件        566  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__javax_persistence_persistence_api_1_0.xml

     文件        611  2018-04-03 10:00  zjkjerseydemo\.idea\libraries\Maven__javax_validation_validation_api_1_1_0_Final.xml

     文件        556  2018-04-03 10:00  zjkjerseydemo\.idea\libraries\Maven__javax_ws_rs_javax_ws_rs_api_2_0_1.xml

     文件        437  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__jstl_jstl_1_2.xml

     文件        455  2018-04-02 17:57  zjkjerseydemo\.idea\libraries\Maven__junit_junit_4_12.xml

............此处省略149个文件信息

评论

共有 条评论