零配置的意思并不是说没有配置,而是通过约定大于配置的方式,大量通过约定来调度页面的跳转而使得配置大大减少。

<?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零配置的更多相关文章

  1. struts2 Convention插件零配置,使用注解开发

    从struts21开始,struts2不再推荐使用codebehind作为零配置插件,而是改用Convention插件来支持零配置.与以前相比较,Convention插件更彻底. 使用Conventi ...

  2. Struts2 Convention Plugin ( struts2 零配置 )

    Struts2 Convention Plugin ( struts2 零配置 ) convention-plugin 可以用来实现 struts2 的零配置.零配置的意思并不是说没有配置,而是通过约 ...

  3. struts2 convention-plugin实现零配置

    零配置并不是没有配置,而是通过约定大于配置的方式,大量通过约定来调度页面的跳转而使得配置大大减少.使得Action等配置不必写在Struts.xml中. convention-plugin的约定 1. ...

  4. Struts2+jQuery+Json零配置实现ajax

    (一)Jsp页面代码 <%@ page language="java" import="java.util.*" pageEncoding="U ...

  5. struts2注解驱动 零配置

    一.配置web.xml<filter><filter-name>struts2</filter-name><filter-class>org.apach ...

  6. 菜鸟学Struts2——零配置(Convention )

    又是周末,继续Struts2的学习,之前学习了,Struts的原理,Actions以及Results,今天对对Struts的Convention Plugin进行学习,如下图: Struts Conv ...

  7. struts2采用convention-plugin实现零配置

    最近开始关注struts2的新特性,从这个版本开始,Struts开始使用convention-plugin代替codebehind-plugin来实现struts的零配置. 配置文件精简了,的确是简便 ...

  8. struts2的零配置

    最近开始关注struts2的新特性,从这个版本开始,Struts开始使用convention-plugin代替codebehind-plugin来实现struts的零配置.配置文件精简了,的确是简便了 ...

  9. struts2 Convention插件好处及使用

    现在JAVA开发都流行SSH.而很大部分公司也使用了struts2进行开发..因为struts2提供了很多插件和标签方便使用..在之前开发过程中总发现使用了struts2会出现很多相应的配合文件.如果 ...

  10. 从struts2.1开始Convention零配置

    从struts2.1开始,struts2不再推荐使用Codebehind作为零配置插件,而是改为使用Convention插件来支持零配置,和Codebehind相比,Convention插件更彻底,该 ...

随机推荐

  1. Github pages博客搭建与域名绑定

    Github Page github page是由用户编写的托管在github上的静态网页,为了搭建一个个人博客,我们可以租用一个云服务器然后部署我们的博客项目,常见的比如wordpress,像wp这 ...

  2. Restrictions----用法

    ----------------------------------------方法说明 --------------------------QBC常用限定方法-------------------- ...

  3. vue笔记一:设置表头的背景颜色以及下边框颜色

    最近做的一个项目有个小小的需求,就是把表头的背景颜色改为黑色,表格边框颜色改为这个颜色,中间出了些问题,因为vue的表格样式是内联样式,一修改就影响到其他地方的表格样式,尽管我单独加了id还是不行,经 ...

  4. Python 生成json文件

    1.数据准备 数据下载 2.python代码 import datetime import os import mssqlhelper ms = mssqlhelper.MSSQL(host=&quo ...

  5. word文档操作

    1.如何把word文档修改的地方标记出来   :  https://zhidao.baidu.com/question/73648149.html 2.word 的几种 视图:https://zhid ...

  6. [NOIP模拟测试7]visit 题解(组合数学+CRT+Lucas定理)

    Orz 因为有T的限制,所以不难搞出来一个$O(T^3)$的暴力dp 但我没试 据说有30分? 正解的话显然是组合数学啦 首先$n,m$可能为负,但这并没有影响, 我们可以都把它搞成正的 即都看作向右 ...

  7. 探索C++的秘密之详解extern

    转载:http://developer.51cto.com/art/200704/46843.htm C和C++对函数的处理方式是不同的.extern "C"是使C++能够调用C写 ...

  8. CSS:CSS 提示工具(Tooltip)

    ylbtech-CSS:CSS 提示工具(Tooltip) 1.返回顶部 1. CSS 提示工具(Tooltip) 本文我们为大家介绍如何使用 HTML 与 CSS 来创建提示工具. 提示工具在鼠标移 ...

  9. C++——异常

    1.throw表达式 if (item1.isbn()!=item2.isbn()) throw runtime_error("data must refer to the same ISB ...

  10. c程序查找字符出现次数

    #include <stdio.h> int main(){ char str[100],ch,M,Empty; int i, frequency = 0; fgets(str, (siz ...