public class TestOne {
public static void main(String[] args) {
/**
*
* JSP全称:JavaServer pages
* JSTL : JavaServer Pages Standard Tags Languages JSP标准标签库
*
* 1。视图解析器的基础知识
*
* SpringMVC定义了两个接口
* ViewResolver 与 View
* ViewResolver :
* 传入视图名和Local对象,返回一个View实例
* public View resolveViewName(String arg0, Locale arg1) throws Exception {
*
* View:
* public void render(Map<String, ?> arg0, HttpServletRequest arg1, HttpServletResponse arg2) throws Exception {
*
* 接受数据模型了request 和response,并把结果输出到response中。
*
*
*
* Spring自带了13种视图解析器
*
*
* BeanNameViewReslver 将视图解析为spring应用上下文中的bean,其中bean的id和视图名相同。
* InternalResourceViewResolver 将视图解析为web应用的内部资源
*
* PS:
* ThymeLeaf是一种代替jsp的新型技术。
*
*
* 2.将视图解析为JstlView(即支持JSTL) InternalResourceViewResolver 设置setViewClass即可
*
* 内部资源访问
*
* 两种配置方式:@Bean 或者xml
*
*
*
*
* 3.Spring的JSP库
* 标签能够避免在JSP中code Java代码
* 两种标签库
* 1)渲染HTML表单标签
* 2)工具类标签
*
* Spring的表单绑定JSP标签库包含了14个标签。与原生的HTML标签不同之处是会绑定一个数据模型对象。
* 使用表单绑定库需要对其声明注册。
* <%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf"%>
*
*
*
* 展现国际化信息<s:message..
* ResourceBundleMessageSource 试图在根路径属性文件中解析信息
* ReloadResourceBundleMessageSource不用重新编译或重启
*
* 三种路径
* classpath:类路径
* file:文件路径
* 不写:web内部路径
*
*
* 创建url <s:url...
*
* 1)预先接受一个相对于servlet上下文的url(request.getContextPath)
* 2)设置作用域 scope=""
* 3)渲染转义后的url htmlEscape="true"
* 4)在js代码里使用url javaScriptEscape="true"
*
*/
}
}
<%@ page language="java" contentType="text/html; charset=utf-8""
pageEncoding="utf-8"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<s:message code="first" ></s:message>
<a href='<s:url value="/split/register"></s:url>'></a>
<s:url value="/spitter/register" var="register" scope="request" htmlEscape="true" javaScriptEscape="true">
<s:param name="max" value="6"></s:param>
<s:param name="count" value="20" ></s:param>
</s:url>
<a href="${register }"></a>
</body>
</html>