博客
关于我
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/

你可能感兴趣的文章
NISP一级,NISP二级报考说明,零基础入门到精通,收藏这篇就够了
查看>>
NI笔试——大数加法
查看>>
NLP 基于kashgari和BERT实现中文命名实体识别(NER)
查看>>
Nmap扫描教程之Nmap基础知识
查看>>
Nmap端口扫描工具Windows安装和命令大全(非常详细)零基础入门到精通,收藏这篇就够了
查看>>
NMAP网络扫描工具的安装与使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>
NO.23 ZenTaoPHP目录结构
查看>>