Java Spring@Controller方法返回奇怪的下载异常
我在Spring MVC应用程序中返回了一个奇怪的错误。当我试图通过Java Spring@Controller方法返回奇怪的下载异常,java,spring,spring-mvc,Java,Spring,Spring Mvc,我在Spring MVC应用程序中返回了一个奇怪的错误。当我试图通过@RestController方法保存用户时,浏览器似乎将该操作解释为下载应用程序的请求。有关此问题的一些信息: 仅当我的应用程序部署到远程服务器上时才会返回(在本地按预期工作) 这仅在Internet Explorer中发生 以下是错误: 细节 OPERATION PROGRESS STATUS * [7/8/2015 6:56:16 PM] : Activation of mySite.com/myApp/sa
@RestController
方法保存用户时,浏览器似乎将该操作解释为下载应用程序的请求。有关此问题的一些信息:
- 仅当我的应用程序部署到远程服务器上时才会返回(在本地按预期工作)
- 这仅在Internet Explorer中发生
OPERATION PROGRESS STATUS
* [7/8/2015 6:56:16 PM] : Activation of mySite.com/myApp/saveUser/100 has started.
ERROR DETAILS
Following errors were detected during this operation.
* [7/8/2015 6:56:17 PM] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
- Downloading mySite.com/myApp/saveUser/100 did not succeed.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
at System.Deployment.Application.DownloadManager.DownloadManifestAsRawFile(Uri& sourceUri, String targetPath, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
--- Inner Exception ---
System.Net.WebException
- The remote server returned an error: (405) Method Not Allowed.
- Source: System
- Stack trace:
at System.Net.HttpWebRequest.GetResponse()
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
这是我的控制器:
@RequestMapping(value = "/saveUser/{id}", method = RequestMethod.POST)
public String saveUser(@ModelAttribute("user") User user, @PathVariable Long id, Model model) {
model.addAttribute("user", user);
userRepo.save(user);
return "success";
}
该方法非常简单,我没有指定任何响应头。你知道为什么会这样吗
更新捕获网络流量时,远程服务器上的POST方法类型是
application/x-ms-application
,其中在我的本地机器上的类型是标准的text/html
显式地将products
属性设置为“text/html”
似乎解决了这个问题
@RequestMapping(value = "/saveUser/{id}", produces="text/html", method = RequestMethod.POST)
从
使用products条件可确保使用的实际内容类型
根据中指定的媒体类型生成响应
产生条件
将
products
属性显式设置为“text/html”
似乎解决了这个问题
@RequestMapping(value = "/saveUser/{id}", produces="text/html", method = RequestMethod.POST)
从
使用products条件可确保使用的实际内容类型
根据中指定的媒体类型生成响应
产生条件