您好,我按您发的步骤,访问http://localhost:8080/swagger.json 是可以正常出数据的如下:{
"swagger": "2.0",
"paths": {
"/swagger/getUserInfo": {
"get": {
"summary": "获取用户信息",
"description": "获取用户信息",
"operationId": "getUserInfo",
"parameters": [],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "string"
}
}
}
}
},
"/swagger/ping": {
"get": {
"summary": "心跳接口",
"description": "发我一个ping,回你一个pong",
"operationId": "ping",
"parameters": [],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "object"
}
}
}
}
}
}
}
可是我访问您说的地址:http://localhost:8080/swagger 确没有响应。 这是什么原因呢
https://nutz.cn/swagger 有页面,报错,没api显示
https://nutz.cn/swagger/ 有页面,无报错,有api显示
This localhost page can’t be found
No webpage was found for the web address: http://localhost:8080/swagger/
Search Google for localhost 8080 swagger
HTTP ERROR 404
我加上反斜杠跟不加 返回的内容是一样的。
是的。不过我换成两层的这样还是响应失败。http://localhost:8080/swagger/swagger.json 这个是有接口数据的
http://localhost:8080/swagger/swagger/ 这样返回的结果:
This localhost page can’t be found
No webpage was found for the web address: http://localhost:8080/swagger/swagger/
Search Google for localhost 8080 swagger
HTTP ERROR 404
我是不是缺少什么配置呢?
web.xml 贴一下
来自美丽的 NutzCN
我给过的地址有
http://localhost:8080/nutzcn/swagger/
http://localhost:8080/nutzcn/swagger/swagger.json
其中nutzcn是项目名(或者ContextPath的值), 项目部署在根的话就空字符串
http://localhost:8080/swagger/
http://localhost:8080/swagger/swagger.json
web.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp"
xmlns:web="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
videodot
/authtaglib
/WEB-INF/tags/authtaglib.tld
480
com.kuyun.videodot.listener.SessionRedisListener
<filter>
<filter-name>DruidWebStatFilter</filter-name>
<filter-class>
com.alibaba.druid.support.http.WebStatFilter
</filter-class>
<init-param>
<param-name>exclusions</param-name>
<param-value>
*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*,/rs/*
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>DruidWebStatFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>nutz</filter-name>
<filter-class>org.nutz.mvc.NutFilter</filter-class>
<init-param>
<param-name>modules</param-name>
<param-value>
com.kuyun.videodot.startup.MainModule
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>nutz</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>DruidStatView</servlet-name>
<servlet-class>
com.alibaba.druid.support.http.StatViewServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DruidStatView</servlet-name>
<url-pattern>/druid/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
刚刚上面的一段格式不知道怎么坏了。
videodot
/authtaglib
/WEB-INF/tags/authtaglib.tld
480
com.kuyun.videodot.listener.SessionRedisListener
是这些。
再发一次。
@wendal 请问@path注解是nutz的还是swagger的, 我用的是swagger3.6, nutz1.r.63有几个api和注解没有