解决 spring mvc 返回ModelAndView设置viewName无效
来源:互联网 发布:js图片无缝滚动代码 编辑:程序博客网 时间:2024/06/05 12:49
比如代码是:
package com.spring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
@Controller
@RequestMapping("/index")
public class IndexController {
@RequestMapping("/test")
public ModelAndView index(){
ModelAndView mav = new ModelAndView();
mav.setViewName("/index/hello");
return mav;
}
}
不管怎么样跳转的jsp都是index文件夹下面的test.jsp。郁闷了很久,结果是引包错误了。
package com.spring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/index")
public class IndexController {
@RequestMapping("/test")
public ModelAndView index(){
ModelAndView mav = new ModelAndView();
mav.setViewName("/index/hello");
return mav;
}
}
这样就可以了
阅读全文
1 0
- 解决 spring mvc 返回ModelAndView设置viewName无效
- spring mvc传入json返回modelAndView
- 【Spring】Spring MVC返回ModelAndView,视图解析器找不到jsp
- spring mvc中返回ModelAndView后执行ajax异步请求
- Spring MVC ModelAndView
- spring mvc ModelAndView
- Spring MVC ModelAndView
- Spring MVC ModelAndView 简述
- Spring MVC ModelAndView
- Spring MVC ModelAndView详解
- Spring MVC ---ModelAndView
- Spring MVC 返回乱码解决
- spring mvc ModelAndView向前台传值
- spring mvc ModelAndView 404 错误
- spring mvc ModelAndView向前台传值
- Spring MVC之ModelAndView分析
- spring mvc 返回方式:ModelAndView, Model, ModelMap, Map,View, String, void
- spring mvc 处理方法的返回方式:ModelAndView, Model, ModelMap, Map,View, String, void
- Laravel 引入第三方类库及自定义函数
- poj2096 Collecting Bugs
- 我的博客即将入驻“云栖社区”,诚邀技术同仁一同入驻。
- 开博了
- oracle去重
- 解决 spring mvc 返回ModelAndView设置viewName无效
- 【Algorithm】 重叠部分面积计算
- ffmpeg error LNK2026: 模块对于 SAFESEH 映像是不安全的
- C程序的执行过程——《C和指针》读书笔记
- db2 原因码68
- TensorFlow如何充分使用所有CPU核数,提高TensorFlow的CPU使用率,以及Intel的MKL加速
- 周中训练笔记(二)
- 侧滑栏实现点击传值
- 如何理解tomcat的server.xml中host、context的标签配置