Restclient accessing SPRINGMVC Java Engineering interface

Source: Internet
Author: User

One, Tomcat and Nginx configuration

/etc/nginx/conf.d/default.conf

location/nsx{
Proxy_pass HTTP://NSX;
Proxy_connect_timeout 30s;
Proxy_read_timeout 30s;
Proxy_send_timeout 30s;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
}

Upstream nsx{
Ip_hash;
Server 10.15.21.134:8095;

2, Tomcat configuration Server.xml, 3 ports.

Second, the project attention point

/opt/skyform/skyform-cmdb/webapps/cmdbapi
1, Tomcat under the war package after decompression folder name must be with the Nginx configuration file
/etc/nginx/conf.d/default.conf definition Consistent
location/cmdbapi{

2, http://physical; is the project package name
Http://localhost:8080/cmdbapi/network/test
Network/test in the control layer code settings.

3. If the war package is Root.war (without the version number) into Tomcat
No project name, HTTP URL access,
You need to set/nsx/network/test in the control class of the engineering code
(to include the project URL)
Http://localhost:8080/nsx/network/test

4, before the URL access test, you must ensure that Tomcat boot normal, Linux must look at the Tomcat log file
Locating logs
/var/log/nginx/error.log
/tomcat/logs/catalina.log

Third, access the rest interface using the Restclient tool

1, get general Get query interface, do not set body

2. Post Access

Set the message header Content-type=application/json

Send body set JSON format

{
"AccountId": "Jyjtest1"
}

Response Body:json Format

    1. {
    2. " msg": "Lstalledge is empty." ,
    3. " networkid": "",
    4. " Success": "fail"
    5. }

Restclient accessing SPRINGMVC Java Engineering interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.