在学习jfinal的时候,遇到一个奇怪的问题 Access to XMLHttpRequest at ‘http://127.0.0.1:8080/izhicheng/login/login’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response. 最后发现是因为网页的url用的是localhost,而请求接口的url用的是127.0.0.1,导致的跨域问题,只要两个都用ip或者都用主机名就不会出现问题了