• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
    當前位置: 首頁 - 科技 - 知識百科 - 正文

    spring mvc整合freemarker基于注解方式

    來源:懂視網(wǎng) 責編:小采 時間:2020-11-27 22:41:35
    文檔

    spring mvc整合freemarker基于注解方式

    spring mvc整合freemarker基于注解方式:基于網(wǎng)絡(luò)改進為:最正常版本 代碼如下:<xml version=1.0 encoding=UTF-8> <beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema
    推薦度:
    導讀spring mvc整合freemarker基于注解方式:基于網(wǎng)絡(luò)改進為:最正常版本 代碼如下:<xml version=1.0 encoding=UTF-8> <beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema

    基于網(wǎng)絡(luò)改進為:最正常版本
    代碼如下:
    <?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="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-2.5.xsd">

        <!-- 針對freemarker的視圖配置 -->
        <bean id="viewResolver"
            class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
            <property name="order" value="5" />
            <property name="suffix" value=".ftl" />
            <property name="contentType" value="text/html;charset=UTF-8" />
        </bean>

         
    <bean id="freemarkerConfig"
            class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
            <property name="templateLoaderPath" value="/WEB-INF/view/" />
            <property name="freemarkerSettings">
                <props>
                    <prop key="template_update_delay">0</prop>
                    <prop key="default_encoding">UTF-8</prop>
                    <prop key="number_format">0.##########</prop>
                    <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
                    <prop key="classic_compatible">true</prop>
                    <prop key="template_exception_handler">ignore</prop>
                </props>
            </property>
        </bean>

    Controller建立
    代碼如下:
    import javax.servlet.http.HttpServletRequest;

    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.servlet.ModelAndView;

    @Controller
    public class SpringMvcController {

        @RequestMapping(value="/welcome",method={RequestMethod.GET}) 
        public ModelAndView getFirstPage(HttpServletRequest request) {
            //welcom就是視圖的名稱(welcom.ftl)
            ModelAndView mv = new ModelAndView("welcom");
            mv.addObject("name", "My First Spring Mvc");
            return mv;
        }
    }

    在url上敲http://localhost:8080/welcome就會到WEB-INF/view/welcom.ftl頁面渲染數(shù)據(jù)
    welcom.ftl頁面
    代碼如下:


    <!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=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    Hello ${name}
    </body>
    </html>

    頁面出來的效果:
    Hello My First Spring Mvc

    聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    spring mvc整合freemarker基于注解方式

    spring mvc整合freemarker基于注解方式:基于網(wǎng)絡(luò)改進為:最正常版本 代碼如下:<xml version=1.0 encoding=UTF-8> <beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema
    推薦度:
    標簽: spring mvc 注解方式
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 国产精品无码一区二区在线观一| 精品国产福利盛宴在线观看| 精品国产一区二区三区久久蜜臀| 精品国产三级a∨在线| 久久成人精品| 91精品啪在线观看国产电影| 精品福利视频一区二区三区| 亚洲一区精品伊人久久伊人| 国产精品永久久久久久久久久| 国产精品一区二区久久精品无码| 国产精品JIZZ在线观看老狼| 97久久久精品综合88久久| 一本一本久久a久久精品综合麻豆 一本色道久久88综合日韩精品 | 日韩三级精品| 国产线视频精品免费观看视频| 亚洲精品高清视频| 国产精品视频第一页| 91麻豆精品国产| 国产区精品一区二区不卡中文 | 在线精品视频播放| 精品国产自在在线在线观看| 国产精品香港三级国产AV| 欧美精品亚洲精品日韩传电影| 亚洲精品午夜无码电影网| 一本久久a久久精品亚洲| 亚洲国产精品尤物yw在线| 全国精品一区二区在线观看| 久久久久人妻一区精品| 欧美成人精品第一区二区 | 国产精品免费视频观看拍拍| 91精品国产91久久久久久青草| 久久国产精品-国产精品| 国产伦精品一区二区三区女| 国产精品福利在线观看| 国产精品莉莉欧美自在线线| 国产精品视频一区二区三区| 国产日韩精品在线| 91探花国产综合在线精品| 日本精品在线视频| 成人国产一区二区三区精品 | 欧美高清在线精品一区|