【发布时间】:2016-07-01 10:28:36
【问题描述】:
我正在使用在 localhost:8080 上运行的 Spring Boot MVC 应用程序。
我想从我的 Angularjs 应用程序中访问它,该应用程序位于 localhost/public 上运行的 xampp htdocs 文件夹中。
当我在 Spring 控制器中使用它时,Angular 服务中的 Cors 已启用并正常工作:
import org.springframework.web.bind.annotation.CrossOrigin;
@RestController
@CrossOrigin(origins = "http://localhost/public", maxAge = 3600)
@RequestMapping("/application")
public class applicationController{
@Autowired
private applicationRepository applicationrepository;
@RequestMapping(method=RequestMethod.GET)
public List<StudentApplication> list() {
return applicationrepository.findAll();
}
}
访问此端点时出现此错误:
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character (CR or LF) found in method name
关于这个问题的任何帮助?
【问题讨论】:
-
错误来自 Tomcat,它表明它收到了一个包含无效字符的方法名称(
GET、POST` 等)的 HTTP 请求。您如何访问端点?似乎正在发送格式错误的 HTTP 请求