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

你可能感兴趣的文章
notepad如何自动对齐_notepad++怎么自动排版
查看>>
Notes on Paul Irish's "Things I learned from the jQuery source" casts
查看>>
Notification 使用详解(很全
查看>>
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
查看>>
NotImplementedError: Could not run torchvision::nms
查看>>
nova基于ubs机制扩展scheduler-filter
查看>>
Now trying to drop the old temporary tablespace, the session hangs.
查看>>
nowcoder—Beauty of Trees
查看>>
np.arange()和np.linspace()绘制logistic回归图像时得到不同的结果?
查看>>
np.power的使用
查看>>
NPM 2FA双重认证的设置方法
查看>>
npm build报错Cannot find module ‘webpack/lib/rules/BasicEffectRulePlugin‘解决方法
查看>>
npm build报错Cannot find module ‘webpack‘解决方法
查看>>
npm ERR! ERESOLVE could not resolve报错
查看>>
npm ERR! fatal: unable to connect to github.com:
查看>>
npm ERR! Unexpected end of JSON input while parsing near '...on":"0.10.3","direc to'
查看>>
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解决方法
查看>>