zoukankan      html  css  js  c++  java
  • SpringMVC 3 视图解析器和JSP

    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>
  • 相关阅读:
    由“Jasperrpeorts 4.1.2升级到5.1.2对flex项目的解析”到AS3 带命名空间的XML的操作
    c++里的类型转化
    A股市场暴跌背后的三大元凶?
    jQuery简单过滤选择器
    Handling of asynchronous events---reference
    NMAP
    JVM Run-Time Data Areas--reference
    Getting over the dangers of rm command in Linux---reference
    45 Useful Oracle Queries--ref
    手动修改user-agent
  • 原文地址:https://www.cnblogs.com/lxh520/p/9136933.html
Copyright © 2011-2022 走看看