SSH Sprong配置 Action 中应用的接口
来源:互联网 发布:js 让某个div不可用 编辑:程序博客网 时间:2024/06/10 20:08
SSH Sprong配置 Action 中应用的接口,bean中配置class属性应为Action中国你调用接口的实现类:
例如:
接口:
//----------------------------------
package com.action.service;
import java.io.IOException;
import java.util.List;
public interface WorkService {
public void WorkZipService(String newpath,String cid,String urlfilename,String zipname,String zippwd) throws Exception ;
public boolean WorkMapCopyService(String oldpath,List<String> sattachmentname,String newp,String cid,List<String> nname) throws Exception;
}
//--------------------------------
接口实现类:
//--------------------------------------
package com.action.serviceimpl;
import java.io.IOException;
import java.util.List;
import com.action.service.WorkService;
import com.bean.Sattachment;
import com.dao.SattachmentDAO;
import com.util.OneUtil;
import com.util.ThreeUtil;
import com.util.TwoUtil;
public class WorkServiceImple implements WorkService {
private SattachmentDAO sattachmentDAO;
public SattachmentDAO getSattachmentDAO() {
return sattachmentDAO;
}
public void setSattachmentDAO(SattachmentDAO sattachmentDAO) {
this.sattachmentDAO = sattachmentDAO;
}
public void WorkZipService(String newpath,String cid, String urlfilename,
String zipname,String zippwd) throws Exception {
// TODO Auto-generated method stub
String pathcid=newpath+"\\"+cid.trim()+"\\";
new ThreeUtil().creatTex(pathcid.trim()+"\\"+urlfilename,pathcid);//pathcid,urlfilename,
new TwoUtil().encryptZip(pathcid,newpath+"\\"+zipname,zippwd);
}
public boolean WorkMapCopyService(String oldpath,
List<String> sattachmentname, String newp, String cid,
List<String> nname) throws Exception {
System.out.println("WorkMapCopyService ");
OneUtil oneutil=new OneUtil();
boolean sn=oneutil.checkMapBeforueZip(oldpath);
System.out.println("checkMapBeforueZip "+sn);
if(sn)
{
if(nname!=null && nname.size()>0)
{
for(int j=0;j<nname.size();j++)
{
List<Sattachment> listsattachment=sattachmentDAO.findAllByNodeName(nname.get(j));
if(listsattachment!=null && listsattachment.size()>0)
{
for(int k=0;k<listsattachment.size();k++)
{
Sattachment sattachment=listsattachment.get(k);
System.out.println("sattachment.getName() "+sattachment.getName());
if(sattachment.getName()!=null && !sattachment.getName().equals(""))
{
sattachmentname.add(sattachment.getName());
}
}
}
}
}
oneutil.copyMap(sattachmentname,oldpath, newp, cid);
return true;
}
return false;
}
}
//---------------------------------------
Action:
//-------------------------------------------
package com.action;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.action.service.WorkService;
import com.bean.Node;
import com.bean.Sattachment;
import com.dao.CourseDAO;
import com.dao.NodeDAO;
import com.dao.SattachmentDAO;
import com.opensymphony.xwork2.ActionSupport;
import com.util.OneUtil;
import com.util.ThreeUtil;
import com.util.TwoUtil;
public class WorkAction extends ActionSupport {
private WorkService workService;
public WorkService getWorkService() {
return workService;
}
public void setWorkService(WorkService workService) {
this.workService = workService;
}
public String workCrouse() throws IOException {
HttpServletRequest request = ServletActionContext.getRequest();
OneUtil oneutil = new OneUtil();
String cid = request.getParameter("cid");
String oldpath = request.getRealPath("Uploadfiles");
String newp = request.getRealPath("czip");
List<Node> node = new ArrayList<Node>();
List<String> nid = new ArrayList<String>();
List<String> nname = new ArrayList<String>();
List<String> sattachmentname=new ArrayList<String>();
String msg="";
boolean sign=true;
if(workService.WorkCheckStr(cid))
{
try
{
node = workService.WorkGetNodeByCid(cid);
for (int i = 0; i < node.size(); i++) {
Node n = node.get(i);
if (n.getCourseid() != null) {
nid.add(n.getId().toString());
if(n.getName()!=null && !n.getName().equals(""))
{
nname.add(n.getName().trim());
}
}
}
sign = workService.WorkCheckCid(newp, cid);
if (sign) {
workService.WorkeCopyCouseMesgge(oldpath, newp, cid, nid);
workService.WorkMapCopyService(oldpath, sattachmentname, newp, cid, nname);
sign = workService.WorkCheckCidBeforueZip(newp,cid);
if(sign)
{
workService.WorkZipService(newp,cid.trim(), "url.txt", cid.trim()+".zip", "12345");
msg="压缩成功!";
}else
{
msg="该课程没有资源信息!";
}
}
else
{
workService.WorkCreaCidFoloder(newp, cid);
workService.WorkeCopyCouseMesgge(oldpath, newp, cid, nid);
workService.WorkMapCopyService(oldpath, sattachmentname, newp, cid, nname);
sign = workService.WorkCheckCidBeforueZip(newp,cid);
if(sign)
{
workService.WorkZipService(newp,cid.trim(), "url.txt", cid.trim()+".zip", "12345");
msg="压缩成功!";
}
else
{
msg="该课程没有资源信息!";
}
}
}
catch(Exception e)
{
msg="该课程没有章节信息!";
node=new ArrayList<Node>();
}
}
else
{
msg="传入参数错误!";
}
request.setAttribute("msg",msg);
return SUCCESS;
}
}
//----------------------------------------
spring xml:
//-------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
............................省略
<bean id="SattachmentDAO" class="com.dao.SattachmentDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="WorkService" class="com.action.serviceimpl.WorkServiceImple">
<property name="sattachmentDAO">
<ref bean="SattachmentDAO"/>
</property>
</bean>
<bean id="workAction" class="com.action.WorkAction">
<property name="workService">
<ref bean="WorkService"/>
</property>
</bean>
</beans>
//-------------------------------------------
- SSH Sprong配置 Action 中应用的接口
- SSH整合中为获取表单对象Action类实现的接口及拦截器配置
- sprong
- SSH中Action配置成多例模式的原因
- Oozie中Shell action的配置及应用
- SSH:Struts2框架(Action的配置)
- ssh中struts2的action的编写
- SSH Action 中Ajax的调用
- SSH中action访问session的方法!
- SSH中action访问session的方法!
- Struts的Action接口--(4)配置默认的Action
- action中json的应用
- SSH中Action
- SSH配置中问题 Unable to instantiate Action
- SSH框架Action中JSON操作及struct.xml配置
- Struts中Action的配置
- struts2中action的配置
- @ACTION中 params 的配置
- 如何提高网站的Google RP值
- ubuntu 12.04 -64位安装使用 fbterm
- Js中的数据类型和变量
- 求最大公约数
- 一位21岁女总裁的忠告,不想穷下去就看看
- SSH Sprong配置 Action 中应用的接口
- 深入浅出JavaScript(1)—ECMAScript .
- VS2010断点设置技巧
- (WPF)360安全卫士界面设计
- CSS+DIV布局之道 .
- Private strand flush not complete
- Js自定义对象(推荐)
- 拓扑排序
- 代码大全学习-10-高质量的函数(High-Quality Routines)