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

你可能感兴趣的文章
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
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 Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
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.
查看>>