spring mvc 3.0使用注解时候怎么选择不同的返回文件类型

问题描述

比如说 使用注解 顶一个 TestController 和一个 Test2Controller里面方法 返回的时候 一个返回 list ---- //打算对应jsp界面 list.jsp一个返回 list //对应html 界面 list.html但是他们都是在方法中返回 return “list”即 在一个文件夹内/info/list.html/info/list.jsp 2个文件在同一个目录中 这个要怎么设置 他们对应不同的

解决方案

很简单,配置视图解析器的时候只配置前置<bean name="viewResovler"class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="viewClass"value="org.springframework.web.servlet.view.JstlView"></property><property name="prefix" value="/WEB-INF/jsp"></property></bean>然后就可以只写后面的目录或者文件名了:return list.html或者return list.jsp

时间: 2024-09-17 04:18:34

spring mvc 3.0使用注解时候怎么选择不同的返回文件类型的相关文章

CRUD using Spring MVC 4.0 RESTful Web Services and AngularJS

国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私募机构九鼎控股打造,九鼎投资是在全国股份转让系统挂牌的公众公司,股票代码为430719,为"中国PE第一股",市值超1000亿元.  ------------------------------------------------------------------------------

spring mvc整合freemarker基于注解方式_实用技巧

基于网络改进为:最正常版本 复制代码 代码如下: <?xml version="1.0" encoding="UTF-8"?> <beans     xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:p="htt

Spring MVC完全注解方式配置web项目_java

在servlet 3.0 开始web项目可以完全不需要web.xml配置文件了,所以本文的配置只在支持servlet 3.0及以上的web容器中有效 使用的是spring mvc (4.3.2.RELEASE) + thymeleaf(3.0.2.RELEASE), 持久层使用的 spring的 JdbcTemplate, PS:推荐一个很好用的对JdbcTemplate封装的框架:https://github.com/selfly/dexcoder-assistant  . 下面开始具体的配置

hibernate+spring mvc, 解决hibernate 对象懒加载 json序列化问题

引用地址 在使用Spring MVC时,@ResponseBody 注解的方法返回一个有懒加载对象的时候出现了异常,以登录为例:   Java代码   @RequestMapping("login")       @ResponseBody       public Object login(@RequestParam String username,@RequestParam String password){           List<User> list=user

No mapping found for HTTP request with URI [/HelloWeb/] in DispatcherServlet with name &amp;#39;HelloWeb&amp;#39; Spring MVC

I'm learning the Spring Framework, and I'm doing the HelloWeb tutorial on tutorialspoint, and I can't get it working. I'm using Spring MVC 4.0, and I'm deploying my app from Netbeans 8.0 to a Glassfish Server. http://www.tutorialspoint.com/spring/spr

【spring MVC学习二】springMVC简单使用

springmvc都是通过其中央控制器DispatcherServlet来进行转发的,所以在web.xml文件里面需要增加相应的配置 1 2 3 4 5 6 7 8 9 10 11 12 13 <servlet>         <servlet-name>springServlet</servlet-name>         <servlet-class>org.springframework.web.servlet.DispatcherServlet&

使用Spring 2.5基于注解驱动的Spring MVC

概述 继 Spring 2.0 对 Spring MVC 进行重大升级后,Spring 2.5 又为 Spring MVC 引入了注解驱动功能.现在你无须让 Controller 继承任何接口,无需在 XML 配置文件中定义请求和 Controller 的映射关系,仅仅使用注解就可以让一个 POJO 具有 Controller 的绝大部分功能 -- Spring MVC 框架的易用性得到了进一步的增强.在框架灵活性.易用性和扩展性上,Spring MVC 已经全面超越了其它的 MVC 框架,伴随

spring mvc-maven spring MVC注解controller页面访问不到。。(新手)

问题描述 maven spring MVC注解controller页面访问不到..(新手) dispatcher-servlet.xml -------------------------------------------------------------------------- <!-- 添加注解驱动 --> <mvc:annotation-driven /> <!-- 默认扫描的包路径 --> <context:component-scan base-p

mvc注解-spring MVC注解 + hibernate +jpa配置 出错 具体如下

问题描述 spring MVC注解 + hibernate +jpa配置 出错 具体如下 这个是错误 No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0 下面为XML配置文件 web.xml 导入hibernate <filter> <filter-name>openEntityManagerInViewFilter&