struts2-convention-plugin零配置
零配置的意思并不是说没有配置,而是通过约定大于配置的方式,大量通过约定来调度页面的跳转而使得配置大大减少。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.3.16.dtd"> <struts>
<!--
使用Convention插件,你需要将其JAR文件convention-plugin放到你应用的WEB-INF/lib目录中,
你也可以在你Maven项目的POM文件中添加下面包依赖
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.1.6</version>
</dependency>
--> <!-- 在开发模式下,struts2的动态重新加载配置和资源文件的功能会默认生效。同时开发模式下也会提供更完善的日志支持。-->
<constant name="struts.devMode" value="true" /> <!-- 主要用于设置请求编码(默认值(UTF-8)) ,Head和Include标签的解析编码。 资源和配置文件的解析编码。-->
<constant name="struts.i18n.encoding" value="UTF-8" /> <!-- 默认所有的结果页面都存储在WEB-INF/content下,你可以通过设置path这个属性的值来改变到其他路径 -->
<constant name="struts.convention.result.path" value="/WEB-INF/page" /> <!-- 自定义jsp文件命名的分隔符 -->
<constant name="struts.convention.action.name.separator" value="_" /> <!-- 配置Convention插件自动重加载映射 是否自动重新编译class文件 -->
<constant name="struts.convention.classes.reload" value="true" /> <!-- 当struts.xml改动后,是否重新加载。默认值为false(生产环境下使用),开发阶段最好打开 -->
<constant name="struts.configuration.xml.reload" value="true"/> <!-- 用于配置类名后缀,默认为Action,设置后,Struts2只会去找这种后缀名的类做映射 -->
<constant name="struts.convention.action.suffix" value="Action" /> <!-- 设置struts的Action请求的后缀,支持多个时以逗号隔开 -->
<constant name="struts.action.extension" value=",shtml" /> <!-- 这个表示包路径包含action和actions的将被视为Action存在的路径来进行搜索-->
<constant name="struts.convention.package.locators" value="action,actions" /> <!-- 不进行扫描的包,用,分割,被包含的包,将不会被扫描成为action -->
<constant name="struts.convention.exclude.packages" value="com.lapp.service" /> <!-- 进行扫描的根包,该包会被扫描成action -->
<constant name="struts.convention.action.packages" value="com.lapp.action" /> <!--
命名空间定义:从.package.locators标示开始到包结束的部分,就是命名空间
Com.ustb.web.user.userAction的命名空间是:”/user”。
Com.ustb.web.user.detail.UserAction的命名空间是:”/user/detail”
-->
<!-- 设置struts2的对象工厂,默认(struts)-->
<constant name="struts.objectFactory" value="spring" /> <!-- 默认返回的结果类型搜索。按顺序先找相关的dispatcher的jsp文件是否存在。然后再找velocity,再找freemarker,jsp -->
<constant name="struts.convention.relative.result.types" value="dispatcher,velocity,freemarker,jsp" /> <package name="default" extends="struts-default">
<interceptors>
<interceptor name="loginInterceptor" class="com.lapp.interceptor.AuthInterceptor" />
<!-- 配置拦截器 Action中用注解:@InterceptorRef("loginStack")-->
<interceptor-stack name="loginStack">
<interceptor-ref name="loginInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack> </interceptors>
<global-results>
<result name="login" type="redirect">/login</result>
</global-results>
</package>
</struts>
struts2-convention-plugin零配置的更多相关文章
- struts2 Convention插件零配置,使用注解开发
从struts21开始,struts2不再推荐使用codebehind作为零配置插件,而是改用Convention插件来支持零配置.与以前相比较,Convention插件更彻底. 使用Conventi ...
- Struts2 Convention Plugin ( struts2 零配置 )
Struts2 Convention Plugin ( struts2 零配置 ) convention-plugin 可以用来实现 struts2 的零配置.零配置的意思并不是说没有配置,而是通过约 ...
- struts2 convention-plugin实现零配置
零配置并不是没有配置,而是通过约定大于配置的方式,大量通过约定来调度页面的跳转而使得配置大大减少.使得Action等配置不必写在Struts.xml中. convention-plugin的约定 1. ...
- Struts2+jQuery+Json零配置实现ajax
(一)Jsp页面代码 <%@ page language="java" import="java.util.*" pageEncoding="U ...
- struts2注解驱动 零配置
一.配置web.xml<filter><filter-name>struts2</filter-name><filter-class>org.apach ...
- 菜鸟学Struts2——零配置(Convention )
又是周末,继续Struts2的学习,之前学习了,Struts的原理,Actions以及Results,今天对对Struts的Convention Plugin进行学习,如下图: Struts Conv ...
- struts2采用convention-plugin实现零配置
最近开始关注struts2的新特性,从这个版本开始,Struts开始使用convention-plugin代替codebehind-plugin来实现struts的零配置. 配置文件精简了,的确是简便 ...
- struts2的零配置
最近开始关注struts2的新特性,从这个版本开始,Struts开始使用convention-plugin代替codebehind-plugin来实现struts的零配置.配置文件精简了,的确是简便了 ...
- struts2 Convention插件好处及使用
现在JAVA开发都流行SSH.而很大部分公司也使用了struts2进行开发..因为struts2提供了很多插件和标签方便使用..在之前开发过程中总发现使用了struts2会出现很多相应的配合文件.如果 ...
- 从struts2.1开始Convention零配置
从struts2.1开始,struts2不再推荐使用Codebehind作为零配置插件,而是改为使用Convention插件来支持零配置,和Codebehind相比,Convention插件更彻底,该 ...
随机推荐
- 2019华工校赛 B - 修仙时在做什么?有没有空?可以来炼丹吗?
题目链接:https://ac.nowcoder.com/acm/contest/625/B 解法:这题其实就是求2^18个点内最近的两个点的距离.我们可以容易想到朴素解法:把每个点作为源点跑最短路取 ...
- PHP-两数相除
给定两个整数,被除数 dividend 和除数 divisor.将两数相除,要求不使用乘法.除法和 mod 运算符. 返回被除数 dividend 除以除数 divisor 得到的商. 示例 1: 输 ...
- position: absolute 如果不设置left, right, top, bottom会在什么位置
一般我们设置position: absolute都会一起设置left/right/top/bottom, 但是如果不设置, 布局会是什么样子的呢? 直接上图 1.一个大盒子中4个小盒子, 正常文档流布 ...
- jeesite框架常用插件
1.分页: <div class="pagination">${page }</div> 2.日历:onclick="WdatePicker({d ...
- spring boot 四大组件之Auto Configuration
SpringBoot 自动配置主要通过 @EnableAutoConfiguration, @Conditional, @EnableConfigurationProperties 或者 @Confi ...
- XML解析方式有哪些?
1.DOM:要求解析器吧整个XML文档装载到内存,并解析成一个Document对象. (1).优点:元素与元素之间保留结构关系,故可以进行增删改查操作. (2).缺点:XML文档过大,可能出现内存溢出 ...
- 批量更新数据(BatchUpdate)
批量更新数据(BatchUpdate) /// <summary> /// 批量更新数据,注意:如果有timestamp列,要移除 /// </summary> /// < ...
- 【LeetCode 5】 最长回文子串
题目链接 描述 [题解] 一个讲得比较好的博客地址; 感觉manacher算法的大概思路就是利用回文串左右对称的性质. 利用之前算出来的以某个点为中心的回文串.而当前要枚举的串被包括在其中. 则可以用 ...
- Android Runnable 运行在那个线程
Runnable 并不一定是新开一个线程,比如下面的调用方法就是运行在UI主线程中的: Handler mHandler=new Handler(); mHandler.post(new Runnab ...
- NGINX配置之一:日志篇
打开nginx.conf配置文件: vi /usr/local/nginx/conf/nginx.conf 日志部分内容: 日志生成的到Nginx根目录logs/access.log文件,默认使用“m ...