今天在开发中遇到了一个问题,控制层使用的是SpringMVC框架。

    @RequestMapping("historyDetail")
private String History(ModelMap model,LedMsgTextInfo condition){
LedMsgTextInfo ledMsgTextInfo;
Long id = condition.getId();
ledMsgTextInfo = ledMsgTextService.getById(id);
List<DeviceLedInfo> ledDeviceList = DeviceLedService.queryLedDeviceList(null);
for(DeviceLedInfo ledInfo:ledDeviceList){
String DeviceCode = ledInfo.getDeviceCode();
if(ledMsgTextInfo.getDeviceCode().equals(DeviceCode)){
ledMsgTextInfo.setDeviceName(ledInfo.getDeviceName());
}
}
model.put("ledDeviceList", ledMsgTextInfo);
return "jtyd/historyDetail";
}

在进行页面跳转时,出现了异常:HTTP Status 500 - Could not resolve view with name ‘jtyd/historyDetail’ in servlet with name ‘dispatcher’

查询网上资料后,有两种类型的错误说明,一种是页面跳转,一种是json返回。

页面跳转:

出现这种异常可能是由于返回值不对,本例中返回值实际上应该是:jtyd/HistoryDetail。仅仅是一个字母的差别。

json返回:

出现这种异常可能是因为在配置文件中配置了:

 <property name="defaultContentType" value="text/html" />

想要纠正就需要改为:

<property name="defaultContentType" value="application/json" />

或者在每一个适配器(请求的方法)上面加上@ResponseBody注解。

个人认为第二种情况出现的错误比较少见,常见的还是第一种情况,即写错了返回值。所以在书写代码的时候一定要注意避免出现书写错误,细心就行。

备注: 
关于第二种配置的问题,个人开发过程中还没有尝试在配置文件中添加返回头的配置,都是通过书写@ResponseBody注解来解决异步请求的返回值处理问题的。

遇到一个比较详细的案例:http://blog.csdn.net/abc360200314/article/details/22862727 
出的问题是一样的,但是解决方式不同,目前还没有去看jar包的问题。

Could not resolve view with name '***' in servlet with name 'dispatcher'的更多相关文章

  1. Spring mvc-异常javax.servlet.ServletException: Could not resolve view with name 'xxx' in servlet with name 'spring'

    最近使用spring mvc开发项目,遇到一个问题: javax.servlet.ServletException: Could not resolve view with name 'ok' in ...

  2. javax.servlet.ServletException: Could not resolve view with name‘ XXXX’in servlet with name 'spring'的解决方案-----SKY

    出现的异常如下: javax.servlet.ServletException: Could not resolve view with name '{"msg":"成功 ...

  3. javax.servlet.ServletException: Could not resolve view with name 'order/list' in servlet with name 'dispatcherServlet'

    javax.servlet.ServletException: Could not resolve view with name 'order/list' in servlet with name ' ...

  4. springMVC+freemarker中Could not resolve view with name... 问题解决

    用到springMVC+freemarker,自己在做demo过程中报: 严重: Servlet.service() for servlet springmvc threw exception jav ...

  5. 深入浅出Java MVC(Model View Controller) ---- (JSP + servlet + javabean实例)

    在DRP中终于接触到了MVC,感触是确实这样的架构系统灵活性不少,现在感触最深的就是使用tomcat作为服务器发布比IIS好多了,起码发布很简单,使用起来方便. 首先来简单的学习一下MVC的基础知识, ...

  6. java.lang.IllegalArgumentException: Failed to register servlet with name 'dispatcher'.Check if there is another servlet registered under the same name

    前言 一年前接手了一个项目,项目始终无法运行,不管咋样,都无法处理,最近,在一次尝试中,终于成功处理了. 含义 意思很明显了,注册了一个相同的dispatcher,可是找了很久,没有相同的Contro ...

  7. Spring MVC 解读——View,ViewResolver(转)

    上一篇文章(1)(2)分析了Spring是如何调用和执行控制器方法,以及处理返回结果的,现在我们就分析下Spring如何解析返回的结果生成响应的视图. 一.概念理解 View ---View接口表示一 ...

  8. freemarker学习 (servlet + freemarker -> Struts2+freemarker -> springMVC+freemarker)

    什么是freemarker? freemarker类似于jsp,但不是jsp!怎么说呢?freemarker文件后缀是.ftl,它不像jsp本质是servlet,它将构建模板.解析模板.使用模板分离开 ...

  9. springMVC源码分析--视图View(一)

    之前的博客springMVC源码分析--HttpMessageConverter数据转化(一)中我们已经介绍了数据返回值的处理,在博客springMVC源码分析--ViewResolver视图解析器( ...

随机推荐

  1. win10 UWP 获取系统信息

    获取系统信息 Windows.System.Profile.AnalyticsVersionInfo analyticsVersion = Windows.System.Profile.Analyti ...

  2. js 查询 添加 删除 练习

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  3. LeetCode 16. 3Sum Closest. (最接近的三数之和)

    Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...

  4. 【20171028早】ubuntu 16.04 LTS 安装php遇到的问题

    背景: 10月28日的一个早上,老黑一如往常地练习,我测试不破坏,当时我找到sqli-libs 游戏,可是我没有立即开始,于是,奇妙的事情就由php开始了.ubuntu16.04安装相关环境 apac ...

  5. Android 6.0运行时权限

    一.Runtime Permissions Android 6.0在手机安全方面做的一个处理就是增加了运行时权限(Runtime Permissions). 新的权限机制更好的保护了用户的隐私,Goo ...

  6. 有两组随机生成的(0~99999)Int32数据A和B,将A按顺序判断在B中是否存在并记录在Boolean型的C中

    http://www.cnblogs.com/asxinyu/p/4504487.html

  7. 暑假练习赛 003 F Mishka and trip

    F - Mishka and trip Sample Output   Hint In the first sample test: In Peter's first test, there's on ...

  8. Java IO编程全解(三)——伪异步IO编程

    转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/7723174.html 前面讲到:Java IO编程全解(二)--传统的BIO编程 为了解决同步阻塞I/O面临 ...

  9. AngularJS学习篇(十)

    AngularJS Select(选择框) 使用 ng-options 创建选择框 在 AngularJS 中我们可以使用 ng-option 指令来创建一个下拉列表,列表项通过对象和数组循环输出,如 ...

  10. aria-label

    元素中的 aria-label用来命名一个元素     它的值可以是任何字符   读屏软件就会读出aria-label里的内容 <div role=”form” aria-labelledby= ...