访问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回答

xiaomo

2019-03-17

对于问题2,请检查下是否类似这样测试POST请求:
//img.mukewang.com/szimg/5c8dc8370001851814350590.jpg

0
0

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
0
0

Go实战仿百度云盘-实现企业级分布式云存储系统

紧随“云时代”技术潮流,分布式云存储系统,做第一代云程序员

1077 学习 · 494 问题

查看课程