---
title: "easyjweb文件配置 "
author: "lovethisworld"
date: "2010-08-16T14:47:54Z"
tags: ["Ajax", "Bean", "Web", "json", "正则表达式"]
categories: ["编程语言"]
slug: "easyjweb"
draft: false
lastmod: "2010-08-19T10:38:39Z"
id: 738418
url: "https://lovethisworld.iteye.com/blog/738418"
---

**1、web.xml**

```
<servlet-mapping>
	<servlet-name>easyjf</servlet-name>
	<url-pattern>/ejf/*</url-pattern>
</servlet-mapping>



```

除\*.ejf外的另一种url形式,demo.ejf?cmd=list&name=lzz等价于/ejf/demo/list/name=lzz,

这种形式的url主要用于Ajax请求,使用Ajax是必须在web.xml中配置

 

```
<context-param>
  <param-name>easyjwebConfigLocation</param-name>
  <param-value>/WEB-INF/easyjf-web1.xml,/WEB-INF/easyjf-web2.xml</param-value>
</context-param>



```

easjweb的默认配置文件是/WEB-INF/easyjf-web.xml,可以修改配置文件路径,如上示,多个文件用','隔开

**2、easyjf-web.xml**

  配置文件根元素easyjf-web下元素有&lt;framework-setting&gt; &lt;modules&gt; &lt;beans&gt; &lt;pages&gt; &lt;forms&gt; &lt;ajax&gt; &lt;import&gt;下面分别介绍：

 

- **framework-setting** ：全局属性设置

```
<framework-setting>    
	<template-base></template-base> <!--模板根目录-->
	<init-app>     					<!--框架初始化程序 -->
		<app-class init-method="" destory-method="">class</app-class>
		...
	</init-app>
	<interceptors>    			<!--全局拦截器 -->
		<app-class name="" method="">class</app-class>
		...
	</interceptors>
	<error-handler>     			<!--错误处理信息 -->
		<app-class exception="" path="">class</app-class>
		...
	</error-handler>
	<property name=""></property>  	<!--全局属性 -->
	...
</framework-setting>



```

...表示允许多个；

template-base模板根目录，默认路径为WEB-INF\\views；

init-app初始程序，在服务启动时执行；interceptors全局拦截器,在处理请求过程中，执行Action的execute前依次执行。

error-handler错误处理，

property全局属性设置：

TemplateBasePath: 模版根目录路径;

com.easyjweb.debug: 是否调试模式;

com.easyjweb.maxUploadFileSize: 文件最大上传值（\*1024）；

com.easyjweb.uploadSizeThreshold：上传文件缓存大小；

com.easyjweb.maxDirectJumpToActionTimes：最大直接跳转Action次数；

com.easyjweb.permissionVerify：是否自动检查权限；

com.easyjweb.messageResourceLoader：设置全局变量Globals.LOAD\_MESSAGE\_RESOURCE\_FROM\_PATH的值为true，这样即可从类加载器加载消息资源，可以提高性能，适合在产品发布的时使用

com.easyjweb.language：设置全局变量Globals.Language的值为指定的语言，这样就可以使得EasyJWeb后台输出指定语言的日志；

com.easyjweb.propertiesType：设置资源文件的默认格式；

com.easyjweb.defaultActionPackages：系统中配置需要扫描的包，多个包用'，'隔开

- **modules** ：模块配置

```
<modules inject="">
	<module name="" action="" path="" form="" autoToken="" alias="" defaultPage="" scope="" inject="" views="" validate="" messageResource="">
		<page name="" type="" url="" contentType="" />
		...
		<property ..>
		...
		<interceptor class="" />
		...
	</module>
	...
</modules>
```

 

  modules的inject默认为none，也可配置bytype,byname，可作为modules内模块的inject属性。

module表示一个模块,action为模块对应的IWebAction，path为请求时路径，如"/demo";alias为模块别名，defaultPage为默认页面，若没有配置，则设第一个page为默认；scope模块的适用 范围，默认为none;inject为属性注入方式，未配置则继承modules的inject属性；views模板视图基础路径，利用module.findPage时则在模板根目录/module.getViews()/下寻找;validate是否执行验证；messageResource配置模板的国际化资源。

page表示模板下的一个页面，可通过module.findPage得到，type有6种:

- - string：根据page的content合成相应的模板，可以利用非本地的page
  - template：利用velocity合成相应页面
  - action：若跳转次数为超过阈值，则重新解析page的url，执行Action
  - forward：根据page的url直接执行dispatch跳转
  - html：执行response.sendRedirect(page.getUrl());
  - null：空结果集页面，表示不返回任何结果集

property表示module的属性注入，具体下面介绍。

interceptor表示模块的拦截器，拦截器需要实现BeforeInterceptor或者AfterInterceptor接口。拦截器在Action的execute钱执行。

- **beans** :容器中bean配置，若bean是ExceptionInterceptor接口的实现类，则自动加入到errorHandler中

```
<beans>
	<bean name="" class="" scope="" factory-method="" inject="">
		<property ..>
		...
		<constructor-arg type="" index="">
			<property ..>
		</constructor-arg>
		...
	</bean>
	...
</beans>



```

    factory-method为bean初始化无参方法，scope默认为singleton，inject默认为bytype;

property为bean的属性注入，具体下面介绍；

constructor-arg表示构造方法参数，type为参数类型，index为参数序号，默认按照出现顺序

- **forms** ：全局表单

```
<forms>
	<form alertType="" bean="" clientValidate="" name="" serverValidate="" event="">
		<property name="" initial="" notNull="" size="" type="" event="" />
		...
	</form>
	...
</forms>



```

- **pages** :全局页面

```
<pages>
	<page name="" type="" url="" contentType="">
	...
</pages>



```

   

- **ajax** ：ajax服务配置

```
<ajax>
	<json-max-depth>depth</json-max-depth>
	<services allowName="" denyNames="">
		<service name="" include="" exclude="">
			<include method="" />
			...
			<exclude method="">
			...
		</service>
		...
	</services>
	<convert name="">
		<include property="" />
		...
		<exclude property="" />
		...
	</convert>
	...
	<signatures>
		多个签名用';'隔开
	</signatures>
</ajax>



```

 

json-max-depth表示设置JSON对象转换的最大深度，当调用ajaxService服务时,返回User示例, 此时所需深度为1，默认为5

services为服务集合，allowName和denyName分别表示允许和禁止的服务名，内容可以有多个，用'，'隔开，内容采用正则表达式匹配方式检测服务名，如allowName="\*Service"表示允许任意以Service结尾的类提供ajax服务，denyName同理，allow且非deny才算合法服务。

service表示一个ajax服务,name必须是一个bean，自动加到service集合的allowName中。include和exclude分别表示允许和禁止的方法，属性内容多个可用','隔开，默认为全部可以。

convert表示需要转换的bean，如调用 ajaxService的方法返回一个User对象， 这就是一个convert。 其 name 必须为类的全路径名，

include和exclude分别表示允许和禁止访问的属性，需要有对应的get方法。

- **import** ：导入其他配置文件

```
<import resource=" " />
...






```

- &lt;**property** ..&gt;:属性注入配置

```
<property name="" value="" ref="">
	<value></value>
	<ref value="">
		<value></value>
	</ref>
	<list>
		<value></value>
		...
	</list>
	<bean name="" class="" />
</property>



```

注入属性类型分别表示Object 、配置的bean、Collection、bean

附件是配置文件对应的一个简单xsd