今天在学习时用maven搭建springMVC环境时出了点问题,请求的action返回值为一个String(值为test) 按照情况下 srpingMVC框架会根据配置的
<!-- 视图加载 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/test/" />
<property name="suffix" value=".jsp" />
</bean>
去寻找/WEB-INF/test文件夹下的test.jsp页面,而实际上通过谷歌浏览器访问的时候一直返回的为test(action的返回结果),而非我们想要的jsp页面。
除此之外,当在ie8下访问该action时报错,错误如下:
平台版本信息
Windows : 6.1.7601.65536 (Win32NT)
Common Language Runtime : 4.0.30319.1026
System.Deployment.dll : 4.0.30319.1029 (RTMGDR.030319-1000)
clr.dll : 4.0.30319.1026 (RTMGDR.030319-1000)
dfdll.dll : 4.0.30319.1029 (RTMGDR.030319-1000)
dfshim.dll : 4.0.31106.0 (Main.031106-0000)
源
部署 URL : http://localhost:8080/test/say.action
错误摘要
以下是错误摘要,这些错误的详细信息列在该日志的后面。
* 激活 http://localhost:8080/test/say.action 导致异常。 检测到下列失败消息:
+ 从 http://localhost:8080/test/say.action 读取清单时出现异常: 清单可能无效,或者文件无法打开。
+ 根级别上的数据无效。 第 1 行,位置 1。
组件存储事务失败摘要
未检测到任何事务错误。
警告
执行此操作的过程中未出现任何警告。
操作进度状态
* [2015/11/9 21:50:03] : 已启动 http://localhost:8080/test/say.action 的激活过程。
错误详细信息
执行此操作期间检测到下列错误。
* [2015/11/9 21:50:11] System.Deployment.Application.InvalidDeploymentException (ManifestParse)
- 从 http://localhost:8080/test/say.action 读取清单时出现异常: 清单可能无效,或者文件无法打开。
- 源: System.Deployment
- 堆栈跟踪:
在 System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
在 System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
在 System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options)
在 System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
在 System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
--- 内部异常 ---
System.Xml.XmlException
- 根级别上的数据无效。 第 1 行,位置 1。
- 源: System.Xml
- 堆栈跟踪:
在 System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
在 System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
在 System.Xml.XmlTextReaderImpl.ParseDocumentContent()
在 System.Deployment.Application.ManifestValidatingReader.XmlFilteredReader.Read()
在 System.Xml.XmlCharCheckingReader.Read()
在 System.Xml.XsdValidatingReader.Read()
在 System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
组件存储事务详细信息
没有可用的事务信息。
查了很多资料,终于找到了原因,原来是因为action的方法配置了多加了一个@ResponseBody。
错误的写法:
@RequestMapping("/test/showTest")
@ResponseBody
public String say(){
return "test";
}
正确的写法:
@RequestMapping("/test/showTest")
public String say(){
return "test";
}
解决方法,去掉方法前的@ResponseBody即可。