访问http://localhost:8080/static/view/signin.html显示404
来源:4-3 编码实战:实现用户登录接口
慕无忌8241360
2019-03-17
1、访问http://localhost:8080/static/view/signin.html显示404 page not found;
2、用POSTMAN测试时使用POST方法访问localhost:8080/user/login可以读取到username,但是读取到的password为空;使用GET方法访问localhost:8080/user/login?username=admin&password=admin可以正常返回。
写回答
2回答
-
对于问题2,请检查下是否类似这样测试POST请求:
00 -
xiaomo
2019-03-17
对于问题1, 请尝试检查下这三个步骤:
1) 登录页面已存在: <你的工程目录>/static/view/signin.html
2)main.go中已经通过http.FileServer来实现对静态资源的处理:
func main() { http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static")))) // ... }3) 在main.go所在的工程根目录路径下启动的程序:
cd <你的工程目录> go run main.go // 或者 go build main.go ./main
00
相似问题
