Angularjs IE9中的上载文件无法使用ng file Upload+;Spring MVC+;OAuth2.0
我对AngularJS一无所知,非常感谢你的帮助 我正在尝试实现一个文件上传页面。它非常简单,用户选择文件并按下上载按钮,它必须上载到后端,这是一个Spring MVC REST web服务。我正试着用它 这是我的前端代码:Angularjs IE9中的上载文件无法使用ng file Upload+;Spring MVC+;OAuth2.0,angularjs,spring-mvc,file-upload,internet-explorer-9,ng-file-upload,Angularjs,Spring Mvc,File Upload,Internet Explorer 9,Ng File Upload,我对AngularJS一无所知,非常感谢你的帮助 我正在尝试实现一个文件上传页面。它非常简单,用户选择文件并按下上载按钮,它必须上载到后端,这是一个Spring MVC REST web服务。我正试着用它 这是我的前端代码: <form name="myForm"> <input type="file" ngf-select ng-model="picFile" name="file accept="application/pdf" ngf-max-size=
<form name="myForm">
<input type="file" ngf-select ng-model="picFile" name="file
accept="application/pdf" ngf-max-size="2MB" required
ngf-model-invalid="errorFiles">
<i ng-show="myForm.file.$error.required">*required</i><br>
<i ng-show="myForm.file.$error.maxSize">File too large
{{errorFiles[0].size / 1000000|number:1}}MB: max 2M</i>
<button ng-disabled="!myForm.$valid" ng-click="uploadFiles(picFile)">Submit</button>
我的后端:
@RequestMapping(value = "/proposals/upload",method = RequestMethod.POST)
@Timed
public ResponseEntity<TemporaryProposal>
uploadProposal(@RequestParam("file") MultipartFile agreementFile){
[DEBUG] com.iocs.portal.aop.logging.LoggingAspect - Enter: org.springframework.boot.actuate.audit.AuditEventRepository.add() with argument[s] = [AuditEvent [timestamp=Tue Mar 01 08:53:23 EST 2016, principal=anonymousUser, type=AUTHORIZATION_FAILURE, data={message=Access is denied, type=org.springframework.security.access.AccessDeniedException}]]
[DEBUG] com.iocs.portal.aop.logging.LoggingAspect - Exit: org.springframework.boot.actuate.audit.AuditEventRepository.add() with result = null
[DEBUG] com.iocs.portal.security.Http401UnauthorizedEntryPoint - Pre-authenticated entry point called. Rejecting access
从后端:
@RequestMapping(value = "/proposals/upload",method = RequestMethod.POST)
@Timed
public ResponseEntity<TemporaryProposal>
uploadProposal(@RequestParam("file") MultipartFile agreementFile){
[DEBUG] com.iocs.portal.aop.logging.LoggingAspect - Enter: org.springframework.boot.actuate.audit.AuditEventRepository.add() with argument[s] = [AuditEvent [timestamp=Tue Mar 01 08:53:23 EST 2016, principal=anonymousUser, type=AUTHORIZATION_FAILURE, data={message=Access is denied, type=org.springframework.security.access.AccessDeniedException}]]
[DEBUG] com.iocs.portal.aop.logging.LoggingAspect - Exit: org.springframework.boot.actuate.audit.AuditEventRepository.add() with result = null
[DEBUG] com.iocs.portal.security.Http401UnauthorizedEntryPoint - Pre-authenticated entry point called. Rejecting access
我通过从前端发送认证参数和请求来解决这个问题。当我使用Auth2身份验证时,在请求中包含令牌是可以的。似乎您的服务器拒绝了请求并发送了一个授权错误。首先让它对chrome起作用,然后你就会更好地了解IE9的问题所在