springmvc整合freemarker配置的详细步骤

网友投稿 380 2023-05-14


springmvc整合freemarker配置的详细步骤

一、对应的导包(有些包是不必须的)

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

4.0.0

com.ming

ssm

war

0.0.1-SNAPSHOT

ssm Maven Webapp

http://maven.apache.org

4.11

3.0.2.RELEASE

3.2.6

1.2.2

1.7.7

1.2.17

1.9.13

1.3.1

2.4

1.9

2.3.23

junit

junit

${junit.version}

test

org.springframework

spring-core

${spring.version}

org.springframework

spring-context-support

${spring.version}

org.springframework

spring-beans

${spring.version}

org.springframework

spring-jdbc

${spring.version}

org.springframework

spring-tx

${spring.version}

org.springframework

spring-web

${spring.version}

org.springframework

spring-webmvc

${spring.version}

org.springframework

spring-oxm

${spring.version}

org.springframework

spring-test

${spring.version}

org.mybatis

mybatis

${mybatis.version}

org.mybatis

mybatis-spring

${mybatis-spring}

javax

javaee-api

7.0

mysql

mysql-connector-java

5.1.30

commons-dbcp

commons-dbcp

1.2.2

jstl

jstl

1.2

log4j

log4j

${log4j.version}

com.alibaba

fastjson

1.1.41

org.slf4j

slf4j-api

${slf4j.version}

org.slf4j

slf4j-log4j12

${slf4j.version}

org.codehaus.jackson

jackson-mapper-asl

${jackson.version}

commons-fileupload

commons-fileupload

${commons-fileupload}

commons-io

commons-io

${commons-io}

commons-codec

commons-codec

${commons-codec}

org.freemarker

freemarker

${freemarker.version}

MyMavens

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

4.0.0

com.ming

ssm

war

0.0.1-SNAPSHOT

ssm Maven Webapp

http://maven.apache.org

4.11

3.0.2.RELEASE

3.2.6

1.2.2

1.7.7

1.2.17

1.9.13

1.3.1

2.4

1.9

2.3.23

junit

junit

${junit.version}

test

org.springframework

spring-core

${spring.version}

org.springframework

spring-context-support

${spring.version}

org.springframework

spring-beans

${spring.version}

org.springframework

spring-jdbc

${spring.version}

org.springframework

spring-tx

${spring.version}

org.springframework

spring-web

${spring.version}

org.springframework

spring-webmvc

${spring.version}

org.springframework

spring-oxm

${spring.version}

org.springframework

spring-test

${spring.version}

org.mybatis

mybatis

${mybatis.version}

org.mybatis

mybatis-spring

${mybatis-spring}

javax

javaee-api

7.0

mysql

mysql-connector-java

5.1.30

commons-dbcp

commons-dbcp

1.2.2

jstl

jstl

1.2

log4j

log4j

${log4j.version}

com.alibaba

fastjson

1.1.41

org.slf4j

slf4j-api

${slf4j.version}

org.slf4j

slf4j-log4j12

${slf4j.version}

org.codehaus.jackson

jackson-mapper-asl

${jackson.version}

commons-fileupload

commons-fileupload

${commons-fileupload}

commons-io

commons-io

${commons-io}

commons-codec

commons-codec

${commons-codec}

org.freemarker

freemarker

${freemarker.version}

MyMavens

二、在spring配置文件中配置

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:p="http://springframework.org/schema/p"

xmlns:context="http://springframework.org/schema/context"

xmlns:mvc="http://springframework.org/schema/mvc"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-3.1.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context-3.1.xsd

http://springframework.org/schema/mvc

http://springframework.org/schema/mvc/spring-mvc-4.0.xsd">

class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">

text/html;charset=UTF-8

class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">

class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">

10

zh_CN

yyyy-MM-dd

yyyy-MM-dd

#.##

class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">

value="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />

class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">

value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

value="org.springframework.web.servlet.view.JstlView" />

class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:p="http://springframework.org/schema/p"

xmlns:context="http://springframework.org/schema/context"

xmlns:mvc="http://springframework.org/schema/mvc"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-3.1.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context-3.1.xsd

http://springframework.org/schema/mvc

http://springframework.org/schema/mvc/spring-mvc-4.0.xsd">

class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">

text/html;charset=UTF-8

class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">

text/html;charset=UTF-8

class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">

class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">

class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">

10

zh_CN

yyyy-MM-dd

yyyy-MM-dd

#.##

class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">

10

zh_CN

yyyy-MM-dd

yyyy-MM-dd

#.##

class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">

value="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />

class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">

value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

value="org.springframework.web.servlet.view.JstlView" />

class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">

value="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />

class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">

value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

value="org.springframework.web.servlet.view.JstlView" />

value="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />

class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">

value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />

class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">

value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />

value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

value="org.springframework.web.servlet.view.JstlView" />

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

value="org.springframework.web.servlet.view.JstlView" />

value="org.springframework.web.servlet.view.JstlView" />

class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

三、jdbc连接 jdbc.properties

driver=com.mysql.jdbc.Driver

url=jdbc:mysql://127.0.0.1:3306/student

username=root

password=

initialSize=0

maxActive=20

maxIdle=20

minIdle=1

maxWait=60000

四、log4j配置

log4j.rootLogger=INFO,Console,File

#\u5B9A\u4E49\u65E5\u5FD7\u8F93\u51FA\u76EE\u7684\u5730\u4E3A\u63A7\u5236\u53F0

log4j.appender.Console=org.apache.log4j.ConsoleAppender

log4j.appender.Console.Target=System.out

#\u53EF\u4EE5\u7075\u6D3B\u5730\u6307\u5B9A\u65E5\u5FD7\u8F93\u51FA\u683C\u5F0F\uFF0C\u4E0B\u9762\u4E00\u884C\u662F\u6307\u5B9A\u5177\u4F53\u7684\u683C\u5F0F

log4j.appender.Console.layout = org.apache.log4j.PatternLayout

log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n

#\u6587\u4EF6\u5927\u5C0F\u5230\u8FBE\u6307\u5B9A\u5C3A\u5BF8\u7684\u65F6\u5019\u4EA7\u751F\u4E00\u4E2A\u65B0\u7684\u6587\u4EF6

log4j.appender.File = org.apache.log4j.RollingFileAppender

#\u6307\u5B9A\u8F93\u51FA\u76EE\u5F55

log4j.appender.File.File = logs/ssm.log

#\u5B9A\u4E49\u6587\u4EF6\u6700\u5927\u5927\u5C0F

log4j.appender.File.MaxFileSize = 10MB

# \u8F93\u51FA\u6240\u4EE5\u65E5\u5FD7\uFF0C\u5982\u679C\u6362\u6210DEBUG\u8868\u793A\u8F93\u51FADEBUG\u4EE5\u4E0A\u7EA7\u522B\u65E5\u5FD7

log4j.appender.File.Threshold = ALL

log4j.appender.File.layout = org.apache.log4j.PatternLayout

log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n

与本项目无关的mybatis配置

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:p="http://springframework.org/schema/p"

xmlns:context="http://springframework.org/schema/context"

xmlns:mvc="http://springframework.org/schema/mvc"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-3.1.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context-3.1.xsd

http://springframework.org/schema/mvc

http://springframework.org/schema/mvc/spring-mvc-4.0.xsd">

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

destroy-method="close">

class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:p="http://springframework.org/schema/p"

xmlns:context="http://springframework.org/schema/context"

xmlns:mvc="http://springframework.org/schema/mvc"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-3.1.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context-3.1.xsd

http://springframework.org/schema/mvc

http://springframework.org/schema/mvc/spring-mvc-4.0.xsd">

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

destroy-method="close">

destroy-method="close">

class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

class="org.springframework.jdbc.datasource.DataSourceTransactionManager">


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:抽象类 实现接口(抽象类实现接口的意义)
下一篇:Java 中的 BufferedWriter 介绍_动力节点Java学院整理
相关文章

 发表评论

暂时没有评论,来抢沙发吧~