qq_27102079 2016-03-22 07:34
浏览 1228

Sprin-test测试Controller,断言报错:No ModelAndView found

问题很奇怪:
使用MockMvc测试SpringMVC的Controller层,调用mockMvc.perform(MockMvcRequestBuilders.post("XXXX")的时候无法调用到Controlelr层的代码,且只要XXX是”/xxx“格式的,返回的状态就一直是200,但结果永远都是null。
1、controller注册了的,我检查了很多遍;
2、controller代码没有被调用到,打了断点测试的;
3、即使是随便输的路径,返回值也是200
输出信息:
Handler:
Type = org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler

Async:
Async started = false
Async result = null

Resolved Exception:
Type = null

ModelAndView:
View name = null
View = null
Model = null

FlashMap:
Attributes = null

MockHttpServletResponse:
Status = 200
Error message = null
Headers = {}
Content type = null
Body =
Forwarded URL = default
Redirected URL = null
Cookies = []

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
    • ¥15 找一个网络防御专家,外包的
    • ¥100 能不能让两张不同的图片md5值一样,(有尝)
    • ¥15 informer代码训练自己的数据集,改参数怎么改
    • ¥15 请看一下,学校实验要求,我需要具体代码
    • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
    • ¥20 MATLAB绘制两隐函数曲面的交线
    • ¥15 求TYPCE母转母转接头24PIN线路板图
    • ¥100 国外网络搭建,有偿交流
    • ¥15 高价求中通快递查询接口