gpt4 book ai didi

java - 如何从 CURL 访问静态端点

转载 作者:行者123 更新时间:2023-12-02 12:03:37 30 4
gpt4 key购买 nike

我有一个简单的嵌入式 tomcat springboot Java 应用程序,部署在 solaris 盒子上。它有一些安静的端点。它们无法通过互联网访问,因为它主要是一个 Java 应用程序。因此,Curl 用于访问静态端点。我的问题是如何访问端点。如何使用GET?

@Controller
public class TopicStatsController {

@Autowired
private QueueDepths depths;

@RequestMapping("/topicDepth")
@ResponseBody
public Long topicDepth() throws Exception {
return depths.topicDepth();
}

@RequestMapping("/subscribersDepth")
@ResponseBody
public List<Long> subscribersDepth() throws Exception {
return depths.subscribersDepth();
}

@RequestMapping("/errorDepth")
@ResponseBody
public Long errorDepth() throws Exception {
return depths.errorDepth();
}

}

我在日志文件中看到的一些信息

org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-11-02 01:42:13,459 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/purgeErrorQueues],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.lang.String> com.bp.pnc.publisher.app.controller.ErrorQueueController.purgeErrorQueues(long)
2017-11-02 01:42:13,465 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/timer],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Double com.bp.pnc.publisher.app.controller.MetricsController.timer(java.lang.String) throws java.lang.Exception
2017-11-02 01:42:13,466 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/gauge],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object com.bp.pnc.publisher.app.controller.MetricsController.gauge(java.lang.String) throws java.lang.Exception
2017-11-02 01:42:13,467 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/counter],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Long com.bp.pnc.publisher.app.controller.MetricsController.counter(java.lang.String) throws java.lang.Exception
2017-11-02 01:42:13,468 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/metricNames],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.Set<java.lang.String> com.bp.pnc.publisher.app.controller.MetricsController.metricNames() throws java.lang.Exception
2017-11-02 01:42:13,471 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/status],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.bp.pnc.publisher.app.domain.StatusDetail com.bp.pnc.publisher.app.controller.StatusInfoController.getStatus()
2017-11-02 01:42:13,475 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/subscribersDepth],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List<java.lang.Long> com.bp.pnc.publisher.app.controller.TopicStatsController.subscribersDepth() throws java.lang.Exception
2017-11-02 01:42:13,476 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/topicDepth],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Long com.bp.pnc.publisher.app.controller.TopicStatsController.topicDepth() throws java.lang.Exception
2017-11-02 01:42:13,477 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/errorDepth],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Long com.bp.pnc.publisher.app.controller.TopicStatsController.errorDepth() throws java.lang.Exception
2017-11-02 01:42:13,528 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-11-02 01:42:13,530 INFO [main] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2017-11-02 01:42:13,906 INFO [main] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-11-02 01:42:13,906 INFO [main] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-11-02 01:42:24,888 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/info],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-11-02 01:42:24,895 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/metrics/{name:.*}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2017-11-02 01:42:24,895 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/metrics],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-11-02 01:42:24,897 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/autoconfig],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-11-02 01:42:24,898 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/beans],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-11-02 01:42:24,899 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/mappings],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-11-02 01:42:24,900 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/trace],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-11-02 01:42:24,901 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/configprops],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-11-02 01:42:24,904 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/env/{name:.*}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2017-11-02 01:42:24,905 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/env],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-11-02 01:42:24,906 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/dump],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-11-02 01:42:24,909 INFO [main] org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/he

最佳答案

为本地计算机上运行的 Web 应用程序创建的 URL 通常采用以下形式:http://localhost:[PORT]/[CONTEXTPAHT]/[CONTROLLER_PATH]

在您的情况下,如果应用程序运行在8080上如果没有设置上下文路径,则 URL 变为 http://localhost:8080/topicDepth等等

关于java - 如何从 CURL 访问静态端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47066608/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com