博客
关于我
springmvc配置文件支持多视图
阅读量:108 次
发布时间:2019-02-26

本文共 894 字,大约阅读时间需要 2 分钟。

Spring MVC配置详解

1. 拦截器配置

Spring MVC拦截器用于统一处理请求前的逻辑,常用的有验证权限、日志记录等功能。以下是拦截器的配置示例:

2. 静态资源访问配置

为了方便管理,通常将静态资源(如图片、CSS、JS)配置在web.xml中。以下是常用的配置方式:

default
*.jpg

也可以通过Spring的<mvc:resources>标签配置:

3. 注解扫描配置

为了自动发现控制器类,需要在springmvc.xml中启用注解扫描:

4. 默认首页配置

默认首页可以通过<mvc:view-controller>标签配置:

5. 多视图配置

支持多种视图(如JSP和Freemarker),可以通过<bean>标签配置视图解析器:

/WEB-INF/common/
/WEB-INF/pages/
2
UTF-8
zh_CN

6. Freemarker模板配置

配置Freemarker视图解析器:

通过以上配置,可以实现JSP和Freemarker视图的无缝集成,同时支持静态资源管理和注解驱动的自动扫描。

转载地址:http://emqy.baihongyu.com/

你可能感兴趣的文章
npm ERR! Unexpected end of JSON input while parsing near ‘...“:“^1.2.0“,“vue-html-‘ npm ERR! A comp
查看>>
npm error Missing script: “server“npm errornpm error Did you mean this?npm error npm run serve
查看>>
npm error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装
查看>>
npm install CERT_HAS_EXPIRED解决方法
查看>>
npm install digital envelope routines::unsupported解决方法
查看>>
npm install 卡着不动的解决方法
查看>>
npm install 报错 EEXIST File exists 的解决方法
查看>>
npm install 报错 ERR_SOCKET_TIMEOUT 的解决方法
查看>>
npm install 报错 Failed to connect to github.com port 443 的解决方法
查看>>
npm install 报错 fatal: unable to connect to github.com 的解决方法
查看>>
npm install 报错 no such file or directory 的解决方法
查看>>
npm install 权限问题
查看>>
npm install报错,证书验证失败unable to get local issuer certificate
查看>>
npm install无法生成node_modules的解决方法
查看>>
npm install的--save和--save-dev使用说明
查看>>
npm node pm2相关问题
查看>>
npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
查看>>
npm run build报Cannot find module错误的解决方法
查看>>
npm run build部署到云服务器中的Nginx(图文配置)
查看>>
npm run dev 和npm dev、npm run start和npm start、npm run serve和npm serve等的区别
查看>>