Skip to content

Controller #3

@yezhaodan

Description

@yezhaodan

package com.yezhaodan;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class Controller {

@Autowired
RestTemplate restTemplate;

@RequestMapping(value="/test",method={RequestMethod.GET})
public void controll(){
	String url = "************************************";
	
	try {
		HttpHeaders headers = AuthenticationUtil.getHttpHeaders();
		HttpEntity<String> entity = new HttpEntity<>(null, headers);
		ResponseEntity<String> resEntity = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
		System.out.println(resEntity);	
	} catch (Exception e) {
		System.out.println("error"+e.getMessage());
	}
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions