資源簡介
java實現的校園二手市場源碼,適合新手參考學習的資料。直接導入java開發IDE中,如myeclipse就可以直接運行。
代碼片段和文件信息
package?cn.edu.djtu.fw.action;
import?java.util.HashMap;
import?java.util.Map;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpSession;
import?org.apache.struts2.interceptor.ServletRequestAware;
import?org.springframework.beans.factory.annotation.Autowired;
import?cn.edu.djtu.fw.model.Admin;
import?cn.edu.djtu.fw.model.Json;
import?cn.edu.djtu.fw.service.AdminServiceI;
import?cn.edu.djtu.fw.util.JsonUtil;
import?com.opensymphony.xwork2.ActionSupport;
public?class?AdminAction?extends?ActionSupport?implements?ServletRequestAware?{
private?static?final?long?serialVersionUID?=?1L;
private?String?id;
private?String?name;
private?String?pwd;
private?HttpServletRequest?request;
private?Admin?admin;
private?int?page;
private?int?rows;
private?String?ids;
@Override
public?String?execute()?throws?Exception?{
Mapject>?m?=?new?HashMapject>();
m?=?adminService.getAllAdmin(page?rows?admin);
JsonUtil.writeJson(m);
return?null;
}
public?String?login()?throws?Exception?{
HttpSession?session?=?request.getSession();
Admin?admin2?=?new?Admin();
Json?j?=?new?Json();
admin2?=?adminService.login(admin);
if?(admin2?!=?null)?{
session.setAttribute(“admin“?admin2);
j.setSuccess(true);
j.setMsg(“登錄成功“);
JsonUtil.writeJson(j);
return?null;
}?else?{
j.setMsg(“登錄失敗“);
JsonUtil.writeJson(j);
return?null;
}
}
public?String?loginOut()?throws?Exception?{
HttpSession?session?=?request.getSession();
if?(session?!=?null?&&?session.getAttribute(“admin“)?!=?null)?{
session.invalidate();
return?SUCCESS;
}
return?ERROR;
}
public?void?add()?throws?Exception?{
Json?j?=?new?Json();
if?(adminService.insert(admin))?{
j.setSuccess(true);
j.setMsg(“添加成功!“);
}?else?{
j.setMsg(“添加失敗!“);
}
JsonUtil.writeJson(j);
}
public?void?delete()?throws?Exception?{
Json?j?=?new?Json();
String[]?idsStr?=?ids.split(““);
for?(int?i?=?0;?i? Admin?a?=?adminService.getAdminById(Integer.parseInt(idsStr[i]));
if?(a?!=?null)?{
adminService.delete(a.getId());
}
}
j.setSuccess(true);
j.setMsg(“刪除成功!“);
JsonUtil.writeJson(j);
}
public?void?update()?throws?Exception?{
Json?j?=?new?Json();
if?(adminService.update(admin))?{
j.setSuccess(true);
j.setMsg(“修改成功!“);
}?else?{
j.setMsg(“修改失敗!“);
}
JsonUtil.writeJson(j);
}
private?AdminServiceI?adminService;
public?AdminServiceI?getAdminService()?{
return?adminService;
}
@Autowired
public?void?setAdminService(AdminServiceI?adminService)?{
this.adminService?=?adminService;
}
public?String?getId()?{
return?id;
}
public?void?setId(String?id)?{
this.id?=?id;
}
public?String?getName()?{
return?name;
}
public?void?setName(String?name)?{
this.name?=?name;
}
public?String?getPwd()?{
return?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-07-23?05:16??fw\
?????文件?????????607??2015-07-23?05:16??fw\README.md
?????目錄???????????0??2015-07-23?05:16??fw\fw\
?????文件?????????727??2015-07-23?05:16??fw\fw\.classpath
?????文件???????????8??2015-07-23?05:16??fw\fw\.gitignore
?????文件????????1035??2015-07-23?05:16??fw\fw\.project
?????目錄???????????0??2015-07-23?05:16??fw\fw\.settings\
?????文件?????????503??2015-07-23?05:16??fw\fw\.settings\.jsdtscope
?????文件?????????364??2015-07-23?05:16??fw\fw\.settings\org.eclipse.jdt.core.prefs
?????文件?????????458??2015-07-23?05:16??fw\fw\.settings\org.eclipse.wst.common.component
?????文件?????????305??2015-07-23?05:16??fw\fw\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件??????????49??2015-07-23?05:16??fw\fw\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件???????????6??2015-07-23?05:16??fw\fw\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????目錄???????????0??2015-07-23?05:16??fw\fw\WebContent\
?????目錄???????????0??2015-07-23?05:16??fw\fw\WebContent\me
?????文件??????????39??2015-07-23?05:16??fw\fw\WebContent\me
?????目錄???????????0??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\
?????目錄???????????0??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\
?????文件????????4467??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\aopalliance-1.0.jar
?????文件???????53232??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\asm-5.0.2.jar
?????文件???????41717??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\asm-commons-5.0.2.jar
?????文件???????29037??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\asm-tree-5.0.2.jar
?????文件?????1791359??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\aspectjweaver-1.7.1.jar
?????文件???????69002??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\commons-fileupload-1.3.1.jar
?????文件??????173587??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\commons-io-2.2.jar
?????文件??????384767??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\commons-lang3-3.2.jar
?????文件???????62050??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\commons-logging-1.1.3.jar
?????文件?????1469339??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\druid-0.2.9.jar
?????文件??????356370??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\fastjson-1.1.26.jar
?????文件??????931168??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\freemarker-2.3.19.jar
?????文件???????45024??2015-07-23?05:16??fw\fw\WebContent\WEB-INF\lib\hamcrest-core-1.3.jar
............此處省略842個文件信息
評論
共有 條評論