请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

访问http://localhost:8080/static/view/signin.html显示404

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 12:08:33

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

0 回复 有任何疑惑可以回复我~
xiaomo 2019-03-17 12:03:27

对于问题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 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号