/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.business.*;
import com.struts.form.PageForm;
import com.struts.form.UpfileForm;
import java.io.*;
import java.util.Vector;
/**
* MyEclipse Struts
* Creation date: 11-14-2008
*
* XDoclet definition:
* @struts.action path="/picmanager" name="upfileForm" scope="request"
*/
public class PicmanagerAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UpfileForm upfileForm = (UpfileForm) form;// TODO Auto-generated method stub
//创建文件对象,并指定文件在服务器上的物理存储位置
String webpath=servlet.getServletContext().getRealPath("");
System.out.println("webpath--->"+webpath);
//获取文件的名称
String filename=upfileForm.getFileform().getFileName();
System.out.println("文件名--->"+filename);
//创建文件对象
File fl=new File(webpath+"/uppic/"+filename);
upfileForm.setFname(filename);
upfileForm.setFpath("/uppic/");
try {
//创建文件输出流对象
FileOutputStream fout=new FileOutputStream(fl);
fout.write(upfileForm.getFileform().getFileData());
fout.flush();
fout.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//保存文件路径等到数据库
PicBusiness picbuss=new PicBusiness();
boolean bl=picbuss.save(upfileForm);
if(bl){
return mapping.findForward("addok");
}
return null;
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UpfileForm upfileForm = (UpfileForm) form;// TODO Auto-generated method stub
//创建文件对象,并指定文件在服务器上的物理存储位置
String webpath=servlet.getServletContext().getRealPath("");
System.out.println("webpath--->"+webpath);
//创建要被删除文件对象
File flold=new File(webpath+"/uppic/"+upfileForm.getFname());
//删除原有文件
if(flold.exists()){
flold.delete();//删除旧文件
}
//获取文件的名称
String filename=upfileForm.getFileform().getFileName();
System.out.println("文件名--->"+filename);
//创建文件对象
File fl=new File(webpath+"/uppic/"+filename);
upfileForm.setFname(filename);
upfileForm.setFpath(webpath+"/uppic/");
try {
//创建文件输出流对象
FileOutputStream fout=new FileOutputStream(fl);
fout.write(upfileForm.getFileform().getFileData());
fout.flush();
fout.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//保存文件路径等到数据库
PicBusiness picbuss=new PicBusiness();
boolean bl=picbuss.update(upfileForm);
if(bl){
return mapping.findForward("updateok");
}
return null;
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id=request.getParameter("pid");
PicBusiness picbuss=new PicBusiness();
UpfileForm uf=(UpfileForm) picbuss.findById(id);
//先删除文件
//创建文件对象,并指定文件在服务器上的物理存储位置
String webpath=servlet.getServletContext().getRealPath("");
System.out.println("webpath--->"+webpath);
//创建要被删除文件对象
File flold=new File(webpath+"/uppic/"+uf.getFname());
//删除原有文件
if(flold.exists()){
flold.delete();//删除旧文件
}
boolean bl=picbuss.delete(id);//删除数据库记录
if(bl){
return mapping.findForward("delok");
}
return null;
}
public ActionForward findById(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id=request.getParameter("pid");
PicBusiness picbuss=new PicBusiness();
UpfileForm uf=(UpfileForm) picbuss.findById(id);
request.setAttribute("ufile", uf);
return mapping.findForward("update");
}
public ActionForward findAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// PicBusiness picbuss=new PicBusiness();
// Vector<UpfileForm> vcpic=picbuss.findAll();
// request.setAttribute("vcpic", vcpic);
HttpSession session=request.getSession(true);
String currpage=request.getParameter("currentpage");
PageForm pf=(PageForm) session.getAttribute("pgf");
if(pf==null){
pf=new PageForm();
}
if(currpage==null){
currpage=""+pf.getCurrentpage();
}
PageBusiness pgbuss=new PageBusiness();
int maxpage=pgbuss.getMaxPage();
int cp=0;
try {
cp = Integer.parseInt(currpage);
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
currpage=""+pf.getCurrentpage();
}
if(cp<1){
cp=1;
}
if(cp>maxpage){
cp=maxpage;
}
pf.setCurrentpage(cp);
pf.setMaxpage(maxpage);
pf.setPagedata(pgbuss.getPageData(cp));
session.setAttribute("pgf", pf);
return mapping.findForward("list");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
strust的复选框自动怎么选中
共44个文件
class:10个
java:10个
tld:6个
需积分: 10 5 下载量 103 浏览量
2008-11-20
01:38:40
上传
评论
收藏 329KB RAR 举报
温馨提示
strust的复选框自动怎么选中,具体的案例,具体的strust标签
资源推荐
资源详情
资源评论
收起资源包目录
prjless32.rar (44个子文件)
prjless32
.project 1KB
.mymetadata 300B
WebRoot
uppic
Ascent.jpg 62KB
WEB-INF
struts-tiles.tld 8KB
.struts-config.mex 2KB
web.xml 1KB
struts-config.xml 1KB
struts-bean.tld 9KB
struts-nested.tld 63KB
struts-html.tld 65KB
struts-template.tld 2KB
struts-logic.tld 14KB
validator-rules.xml 41KB
lib
sqljdbc.jar 247KB
classes
com
dao
PageDao.class 2KB
IDao.class 295B
PicDao.class 3KB
db
DBConnection.class 2KB
business
IBusiness.class 310B
PageBusiness.class 717B
PicBusiness.class 1KB
struts
action
PicmanagerAction.class 5KB
form
PageForm.class 2KB
UpfileForm.class 2KB
ApplicationResources.properties 80B
index.jsp 829B
META-INF
MANIFEST.MF 39B
listpic.jsp 3KB
upfile.jsp 2KB
updatepic.jsp 2KB
无标题1.sql 158B
.myeclipse
src
com
dao
IDao.java 237B
PicDao.java 3KB
PageDao.java 2KB
db
DBConnection.java 986B
business
IBusiness.java 256B
PicBusiness.java 797B
PageBusiness.java 408B
struts
action
PicmanagerAction.java 6KB
form
UpfileForm.java 2KB
PageForm.java 2KB
ApplicationResources.properties 80B
.mystrutsdata 250B
.classpath 523B
共 44 条
- 1
资源评论
songfu1988
- 粉丝: 8
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功