Spring-视图解析

一、转发

第一种

@RequestMapping("/hello")
	public String hello(){
		//   默认WEB-INF/pages/hello.jsp 想要的目标页面:hello.jsp 处理方法:../../
		return "../../hello";
	}

第二种
forward:转发到一个页面
/hello.jsp:转发当前项目下的hello.jsp

一定要加/,不加/为相对路径,易出错

@RequestMapping("/handle01")
	public String handle01(){
		
		return "forward:/hello.jsp";
	}

多级转发

@RequestMapping("/handle02")
	public String handle02(){
		
		return "forward:/handle01";
	}

二、重定向

三、国际化

1.导包
在这里插入图片描述
2.配置

在这里插入图片描述

<!-- 让SpringMVC管理国际化资源文件:配置一个资源文件管理器 -->
	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
		<property name="basename" value="i18n"></property>
	</bean>
	
	<mvc:view-controller path="/toLoginPage" view-name="login"/>
	<!-- 开启mvc注解驱动模式 -->
	<mvc:annotation-driven></mvc:annotation-driven>

在这里插入图片描述
3.页面
在这里插入图片描述

login.jsp

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<body>
<fmt:message key="welcomeinfo"/>
<form action="">
	<fmt:message key="username"/>:<input><br>
	<fmt:message key="password"/>:<input><br>
	<input type="submit" value="<fmt:message key="loginBtn"/>">
</form>
</body>
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值