1. <html:optionsCollection />( 显示一组选项 ) 标签的使用:
<html:select property="parentId" styleClass="input1">
<html:option value="0"> 请选择部门… </html:option>
<html:optionsCollection name="departments" value="id" label="name"/>
</html:select>
注: property 属性指定下拉选框的默认值选取值 ;name 属性代表作用域当中的 Key;value 属性指定要用于传递的值; label 属性指定要在页面中显示的值
2. DepartmentAction 中的 list ()方法显示同级的部门列表,默认显示最顶级的部门列表:根据 parentId 获取要显示部门的父部门( parent ),若 parent 为空,则显示最顶级的部门列表,否则显示同级的部门列表
3. 在显示下拉列表时候,先调用 getSession ()方法开启事务,获得最顶层的部门列表,再获得所有的部门列表,然后对 Deparment 进行修改显示到下拉列表框,这时由于 Session 处于持久状态,对 Department 的修改会写入数据库。解决方案:这里需要在获取最顶层的部门列表之后把作用域中的 Session 清掉,使其不处于持久状态即可 注意:这里需要把子部门的懒加载给予关闭,否则会报错!
4. 路径的重定向: new 一个新的 ActionFoward ,重写 url 地址 例: return new ActionForward(af.getPath() + "&parentId=" + actionForm.getParentId(), af.getRedirect());
5. <html:select/> 标签的 multiple 属性用于设置 select 标签是否可以多选,值为 true 时表示可以多选,反之则只能单选
6. 获取流程定义文件的方法:
ProcessDefinition pd = jbpmContext.getGraphSession().getProcessDefinition(1);
byte[] fileContent = pd.getFileDefinition().getBytes(name); //name 指定文件名
注意:只有部署的是 par, pd.getFileDefinition() 才有数据,否则为 null.
7. zip 打包:
FileOutputStream fos = new FileOutputStream("c:/testZip/testZip.zip");
ZipOutputStream zipOutputStream = new ZipOutputStream(fos);
zipOutputStream.putNextEntry(new ZipEntry("a.txt"));
zipOutputStream.write(new byte[] { 97, 97, 97 });
zipOutputStream.closeEntry(); // 可以不用关闭,它能自动检测关闭
zipOutputStream.close();
8. 解决 zip 中文乱码问题:
1) 使用 ant 中的 ZipOutputStream 和 ZipEntry
2) 使用 Apache 提供的 common-compress 工具包