- 浏览: 513277 次
- 性别:
- 来自: 惠州
文章分类
- 全部博客 (255)
- ant (1)
- springMVC (2)
- ajax (4)
- oracle (12)
- SSH (13)
- struts1 (2)
- Hibernate (14)
- spring (5)
- jstl (1)
- 连接池 (1)
- acegi (4)
- java (17)
- jquery (11)
- div+css (4)
- drupal (1)
- php (8)
- freemaker调模板生成静态页面 (1)
- xml (1)
- json (2)
- javascript (9)
- 正则表达式 (4)
- Ext (8)
- jdbc (1)
- sql server (2)
- perl (5)
- db4o (1)
- webservice (4)
- flex (13)
- it资讯 (1)
- joomla (0)
- 设计模式 (1)
- struts2 (4)
- s2sh (8)
- linux (3)
- ejb (2)
- android旅途 (24)
- android (36)
- C/C++ (16)
- mysql (1)
最新评论
-
fengyuxing168:
IBelyService bs = IBelyService. ...
为 Android 添加 Java 层服务也就是添加自定义的aidl服务到serviceManager 通过ServiceManager.getService取 -
dengzhangtao:
"由于ActivityManagerService是 ...
binder理解 -
yzyspy:
ActivityManagerService:startHom ...
Android的Launcher成为系统中第一个启动的,也是唯一的 -
Matchstick:
使用SELECT DISTINCT alias FROM Po ...
hibernate 一对多表查询时fetchMode.join 生成left outer join 出来数据重复问题 -
dlheart:
没看懂你什么意思啊,我遇到的问题是一对多,设了fetch = ...
hibernate 一对多表查询时fetchMode.join 生成left outer join 出来数据重复问题
1.ExtLoginAction
package com.action;
import java.util.Map;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import com.model.Tuser;
import com.util.MyTool;
import com.common.Constants;
import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import com.service.base.IUserService;
public class ExtLoginAction extends ActionSupport {
//private Logger logger=Logger.getLogger(this.getClass());
private Tuser user=new Tuser();
private IUserService userService;
private String errorMessage;
public Tuser getUser(){
return user;
}
public void setUser(Tuser user) {
this.user = user;
}
public IUserService getUserService() {
return userService;
}
public void setUserService(IUserService userService) {
this.userService = userService;
}
public String extLogin() throws Exception
{
System.out.println("test extloginAction start-----------------");
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setCharacterEncoding("utf-8");
PrintWriter pw = response.getWriter();
MyTool tool=new MyTool();
Constants constants=null;
//System.out.println("username====="+user.getUsername());
//System.out.println("password====="+user.getPassword());
Tuser userRtn=userService.userValid(user);
if(userRtn!=null)
{
Map session = ctx.getSession();
userRtn.setPassword(tool.decode(userRtn.getPassword()));
session.put("user", userRtn);
File f=new File(constants.DOC_PATH+this.user.getUsername());
if(f.exists())
tool.deleteDirs(f);
tool.createDir(constants.DOC_PATH+this.user.getUsername());
pw.print("{success:true,msg:'ok'}");
//return this.SUCCESS;
return null;
}
else
{
setErrorMessage("登陆失败,用户名、密码错误!");
//System.out.println("登陆失败,用户名、密码错误!");
pw.print("{success:true,msg:'用户名或密码错误!'}");
//return this.ERROR;
return null;
}
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}
2.CangDianAddAction
package com.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import com.model.Tuser;
import com.model.Tvmistock;
import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import com.service.base.ITvmistockService;
public class CangDianAddAction extends ActionSupport{
private Tvmistock vmi = new Tvmistock();
private ITvmistockService tvmistockService;
private String errorMessage;
public ITvmistockService getTvmistockService() {
return tvmistockService;
}
public void setTvmistockService(ITvmistockService tvmistockService) {
this.tvmistockService = tvmistockService;
}
public Tvmistock getVmi() {
return vmi;
}
public void setVmi(Tvmistock vmi) {
this.vmi = vmi;
}
//------------新增保存和编辑保存共用--------------------------------
public String cangDianAdd()
{
System.out.println("test cangdian add start-----------------");
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setContentType("text/html;charset=UTF-8");
Map session = ctx.getSession();
Tuser user = (Tuser)session.get("user");
//int pageNo = start/limit+1;
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try{
vmi.setFinsertdate(new Date());
vmi.setFinsertuser(user.getUsername());
vmi.setFupdateuser(user.getUsername());
vmi.setUpdatedate(new Date().toString());
System.out.println("vmi getFid=="+vmi.getFid());
System.out.println("vmi getFaddress=="+vmi.getFaddress());
System.out.println("vmi getFchargeman=="+vmi.getFchargeman());
System.out.println("vmi getFcustcode=="+vmi.getFcustcode());
System.out.println("vmi getFcustsort=="+vmi.getFcustsort());
System.out.println("vmi getFinsertuser=="+vmi.getFinsertuser());
System.out.println("vmi getFremarks=="+vmi.getFremarks());
System.out.println("vmi getFstockcode=="+vmi.getFstockcode());
System.out.println("vmi getFstockname=="+vmi.getFstockname());
System.out.println("vmi getFtel=="+vmi.getFtel());
System.out.println("vmi getFupdateuser=="+vmi.getFupdateuser());
tvmistockService.saveObject(vmi);
out.print("{success:true,data:'save data success!'}");
}catch(Exception e){
e.printStackTrace();
out.print("{success:false,data:'save data fail!'}");
System.out.println(this.getClass()+" add cangdian errors!!!");
}
return null;
}
//--------------------编辑可以和查看共用,只是跳转不同-------------------------------
public String cangDianEdit()
{
System.out.println("test cangdian Edit start-----------------");
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setContentType("text/html;charset=UTF-8");
Map session = ctx.getSession();
Tuser user = (Tuser)session.get("user");
//int pageNo = start/limit+1;
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try{
vmi.setFinsertdate(new Date());
vmi.setFinsertuser(user.getUsername());
//System.out.println("vmi fid================"+vmi.getFid());
Tvmistock tvmi = tvmistockService.findById(vmi.getFid());
JSONArray array = JSONArray.fromObject(tvmi);
//System.out.println("array.toString============"+array.toString());
out.print("{success:true,totalSize:1,data:" + array.toString() + "}");
//out.print("{success:true,data:'save data success!'}");
}catch(Exception e){
e.printStackTrace();
out.print("{success:false,data:'save data fail!'}");
System.out.println(this.getClass()+" add cangdian errors!!!");
}
return null;
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}
3.CangDianAction
package com.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import net.sf.json.JSONArray;
import com.model.Tvmistock;
import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import com.service.base.ITvmistockService;
import com.util.JsonUtil;
public class CangDianAction extends ActionSupport {
// private Logger logger=Logger.getLogger(this.getClass());
private ITvmistockService tvmistockService;
private int start;
private int limit;
private Tvmistock vmi = new Tvmistock();
private String delData;
//---------------一个ext list例子方法--------------------------
//--------delData是ext传过来要删去的记录的id (18,35,46,89)
public String jsonExecute() throws Exception {
if (this.getDelData() != null && !"".equals(this.getDelData())) {
if (this.getDelData().indexOf(",") < 0) {
// this.levelService.removeLevelById(Long.parseLong(this.getDelData()));
System.out.println("del_id:" + getDelData());
} else {
String id[] = this.getDelData().split(",");
for (int i = 0; i < id.length; i++) {
System.out.println("del:" + id[i]);
//this.levelService.removeLevelById(Long.parseLong(id[i]));
}
}
}
HttpSession session = ServletActionContext.getRequest().getSession();
Object o = null;// session.getAttribute("Level_Data1");
if (o == null) {
try {
// this.levels = this.getLevelService().findAllLevels();
//session.setAttribute("Level_Data1", this.levels);
System.out.println("query database");
} catch (Exception e) {
e.printStackTrace();
}
} else {
//this.setLevels(((List<Level>) o));
}
// this.setTotalCount(this.levels.size());
//JSONArray array = JSONArray.fromObject(this.levels);
// System.out.println(this.getStart() + "---" + this.getLimit());
// this.setJsonString("{success:true,totalCount : " + this.getTotalCount() + ", list:" + array.toString() + "}");
// System.out.println(this.getJsonString());
//return super.jsonExecute();
return null;
}
public String list() throws Exception {
List stocklist = tvmistockService.getAll();
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
StringBuffer sb = new StringBuffer();
sb.append("{total:"+stocklist.size()+",rows:[");
int i=1;
for(Iterator ite = stocklist.iterator();ite.hasNext();){
Tvmistock tvmistock = (Tvmistock)ite.next();
if(i==stocklist.size()){
sb.append("{value:'"+tvmistock.getFstockcode()+"',text:'"+tvmistock.getFstockname()+"'}");
}else{
sb.append("{value:'"+tvmistock.getFstockcode()+"',text:'"+tvmistock.getFstockname()+"'},");
}
i++;
}
sb.append("]}");
out.print(sb.toString());
return null;
}
//有分页功能的list
public String listPage() {
//-------------------如果delData有值就先调用删除功能-----------------
System.out.println("deldata===================================="+getDelData());
if (this.getDelData() != null && !"".equals(this.getDelData())) {
if (this.getDelData().indexOf(",") < 0) {
// this.levelService.removeLevelById(Long.parseLong(this.getDelData()));
tvmistockService.removeById(Integer.parseInt(this.getDelData()));
System.out.println("del_id:" + getDelData());
} else {
String id[] = this.getDelData().split(",");
for (int i = 0; i < id.length; i++) {
System.out.println("del:" + id[i]);
tvmistockService.removeById(Integer.parseInt(id[i]));
//this.levelService.removeLevelById(Long.parseLong(id[i]));
}
}
this.setDelData("");//置空
}
//--------------------delete end-----------------------------
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setContentType("text/html;charset=UTF-8");
int pageNo = start/limit+1;
try{
List stocklist = tvmistockService.getAllStockByPage(pageNo, limit, "fstockcode", false);
PrintWriter out = response.getWriter();
JsonUtil ju = new JsonUtil();
StringBuffer sb = new StringBuffer();
sb.append("{totalSize:"+stocklist.size()+",data:[");
int i=1;
for(Iterator ite = stocklist.iterator();ite.hasNext();){
Tvmistock tvmistock = (Tvmistock)ite.next();
if(i==stocklist.size()){
//sb.append(ju.getJsonString4JavaPOJO(tvmistock));
sb.append("{fid:'"+tvmistock.getFid()+"',cangdiancode:'"+tvmistock.getFstockcode()+"',cangdianname:'"+tvmistock.getFstockname()+"',custname:'"+tvmistock.getFcustcode()+"',createdate:'"+tvmistock.getFinsertdate()+"',chargeman:'"+tvmistock.getFcustsort()+"',status:'"+tvmistock.getFstatus()+"'}");
}else{
sb.append("{fid:'"+tvmistock.getFid()+"',cangdiancode:'"+tvmistock.getFstockcode()+"',cangdianname:'"+tvmistock.getFstockname()+"',custname:'"+tvmistock.getFcustcode()+"',createdate:'"+tvmistock.getFinsertdate()+"',chargeman:'"+tvmistock.getFcustsort()+"',status:'"+tvmistock.getFstatus()+"'},");
//sb.append(ju.getJsonString4JavaPOJO(tvmistock)+",");
//sb.append("{value:'"+tvmistock.getFstockcode()+"',text:'"+tvmistock.getFstockname()+"'},");
}
i++;
}
sb.append("]}");
out.print(sb.toString());
System.out.print(sb.toString());
}catch(Exception e){
e.printStackTrace();
System.out.println(this.getClass()+" listPage errors!!!");
}
return null;
}
//新增倉點
public String addCangDian() {
System.out.println("-------------------add start --------------");
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setContentType("text/html;charset=UTF-8");
//int pageNo = start/limit+1;
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try{
System.out.println("vmi getFaddress=="+vmi.getFaddress());
System.out.println("vmi getFchargeman=="+vmi.getFchargeman());
System.out.println("vmi getFcustcode=="+vmi.getFcustcode());
System.out.println("vmi getFcustsort=="+vmi.getFcustsort());
System.out.println("vmi getFinsertuser=="+vmi.getFinsertuser());
System.out.println("vmi getFremarks=="+vmi.getFremarks());
System.out.println("vmi getFstockcode=="+vmi.getFstockcode());
System.out.println("vmi getFstockname=="+vmi.getFstockname());
System.out.println("vmi getFtel=="+vmi.getFtel());
System.out.println("vmi getFupdateuser=="+vmi.getFupdateuser());
tvmistockService.saveObject(vmi);
out.print("{success:true,data:'save data success!'}");
}catch(Exception e){
e.printStackTrace();
out.print("{success:false,data:'save data fail!'}");
System.out.println(this.getClass()+" listPage errors!!!");
}
return null;
}
public ITvmistockService getTvmistockService() {
return tvmistockService;
}
public void setTvmistockService(ITvmistockService tvmistockService) {
this.tvmistockService = tvmistockService;
}
public int getStart() {
return start;
}
public void setStart(int start) {
this.start = start;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public Tvmistock getVmi() {
return vmi;
}
public String getDelData() {
return delData;
}
public void setDelData(String delData) {
this.delData = delData;
}
}
4.xwork.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1.1//EN" "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd">
<xwork>
<include file="webwork-default.xml"/>
<package name="com" extends="webwork-default">
<interceptors>
<interceptor name="auth" class="com.service.AuthenticationInterceptor"/>
<interceptor-stack name="crudStack">
<interceptor-ref name="params" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<action name="login" class="loginAction">
<result name="success">main.jsp</result>
<result name="error">index.jsp</result>
</action>
<action name="extlogin" class="extLoginAction" method="extLogin">
<result name="success">/Inventory/ext_viewport.jsp</result>
<result name="error">ext_login.jsp</result>
</action>
<action name="addcd" class="extLoginAction" method="addCangDian">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
<action name="allmenu" class="getMenuAction" method="allMenu">
<result name="success">MenuBar.jsp</result>
</action>
<action name="extmenu" class="getMenuAction" method="extMenu">
<result name="success">MenuBar.jsp</result>
</action>
<action name="userAct" class="userAction">
<interceptor-ref name="fileUploadStack"></interceptor-ref>
<result name="success">hide.jsp</result>
<result name="error">hide.jsp</result>
</action>
<!-- CaseManage -->
<action name="addCase" class="caseAction" method="addCase">
<result name="success">/admin/code_list.jsp</result>
<result name="error">/admin/code_list.jsp</result>
</action>
<action name="viewCase" class="caseAction" method="viewCase">
<result name="success">/admin/code_list.jsp</result>
</action>
<!-- -->
<!-- CodeManage -->
<action name="addCode" class="codeAction" method="addCode">
<result name="success">/admin/code_list.jsp</result>
</action>
<action name="viewCode" class="codeAction" method="viewCode">
<result name="success">/admin/code_list.jsp</result>
</action>
<action name="deleteCode" class="codeAction" method="deleteCode">
<result name="success">/admin/code_list.jsp</result>
</action>
<action name="editCode" class="codeAction" method="editCode">
<result name="success">/admin/code_edit.jsp</result>
</action>
<action name="updateCode" class="codeAction" method="updateCode">
<result name="success">/admin/code_list.jsp</result>
</action>
<!-- userSetManage -->
<action name="viewUser" class="userSetAction" method="browseUser">
<result name="success">/admin/auth_set.jsp</result>
</action>
<action name="viewUserSet" class="UserSetOperateAction" method="viewUserSet">
<result name="viewsuccess">/admin/auth_set_view.jsp</result>
<result name="editsuccess">/admin/auth_set_edit.jsp</result>
</action>
<action name="updateUserSet" class="UserSetOperateAction" method="updateUserSet">
<result name="success">/admin/auth_set.jsp?curPage=1</result>
</action>
<!--userPrivateView-->
<action name="viewUserPrivate" class="userPrivateAction" method="viewUserPrivate">
<result name="success">userprivate_view.jsp</result>
</action>
<action name="getcangdianjson" class="CangDianAction" method="list">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
<action name="cangdianList" class="CangDianAction" method="listPage">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
<action name="cangdianadd" class="cangDianAddAction" method="cangDianAdd">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
<action name="cangdianedit" class="cangDianAddAction" method="cangDianEdit">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
</package>
<package name="upload" extends="webwork-default">
<interceptors>
<interceptor name="upload" class="com.opensymphony.webwork.interceptor.FileUploadInterceptor"/>
<interceptor-stack name="uploadStack">
<interceptor-ref name="upload"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="WSStack"/>
<action name="userAct" class="userAction">
<interceptor-ref name="uploadStack"/>
<result name="success">hide.jsp</result>
<result name="error">hide.jsp</result>
</action>
<!--custom system uploadFile-->
<action name="uploadFileAct" class="uploadFileAction" method="saveUploadFile">
<interceptor-ref name="uploadStack"/>
<result name="success">uploadFileDeal.jsp</result>
<result name="error">uploadFileDeal.jsp</result>
</action>
</package>
</xwork>
5.原来还少了viewport.jsp和viewport.js文件,在另一编文章中补上
package com.action;
import java.util.Map;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import com.model.Tuser;
import com.util.MyTool;
import com.common.Constants;
import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import com.service.base.IUserService;
public class ExtLoginAction extends ActionSupport {
//private Logger logger=Logger.getLogger(this.getClass());
private Tuser user=new Tuser();
private IUserService userService;
private String errorMessage;
public Tuser getUser(){
return user;
}
public void setUser(Tuser user) {
this.user = user;
}
public IUserService getUserService() {
return userService;
}
public void setUserService(IUserService userService) {
this.userService = userService;
}
public String extLogin() throws Exception
{
System.out.println("test extloginAction start-----------------");
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setCharacterEncoding("utf-8");
PrintWriter pw = response.getWriter();
MyTool tool=new MyTool();
Constants constants=null;
//System.out.println("username====="+user.getUsername());
//System.out.println("password====="+user.getPassword());
Tuser userRtn=userService.userValid(user);
if(userRtn!=null)
{
Map session = ctx.getSession();
userRtn.setPassword(tool.decode(userRtn.getPassword()));
session.put("user", userRtn);
File f=new File(constants.DOC_PATH+this.user.getUsername());
if(f.exists())
tool.deleteDirs(f);
tool.createDir(constants.DOC_PATH+this.user.getUsername());
pw.print("{success:true,msg:'ok'}");
//return this.SUCCESS;
return null;
}
else
{
setErrorMessage("登陆失败,用户名、密码错误!");
//System.out.println("登陆失败,用户名、密码错误!");
pw.print("{success:true,msg:'用户名或密码错误!'}");
//return this.ERROR;
return null;
}
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}
2.CangDianAddAction
package com.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import com.model.Tuser;
import com.model.Tvmistock;
import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import com.service.base.ITvmistockService;
public class CangDianAddAction extends ActionSupport{
private Tvmistock vmi = new Tvmistock();
private ITvmistockService tvmistockService;
private String errorMessage;
public ITvmistockService getTvmistockService() {
return tvmistockService;
}
public void setTvmistockService(ITvmistockService tvmistockService) {
this.tvmistockService = tvmistockService;
}
public Tvmistock getVmi() {
return vmi;
}
public void setVmi(Tvmistock vmi) {
this.vmi = vmi;
}
//------------新增保存和编辑保存共用--------------------------------
public String cangDianAdd()
{
System.out.println("test cangdian add start-----------------");
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setContentType("text/html;charset=UTF-8");
Map session = ctx.getSession();
Tuser user = (Tuser)session.get("user");
//int pageNo = start/limit+1;
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try{
vmi.setFinsertdate(new Date());
vmi.setFinsertuser(user.getUsername());
vmi.setFupdateuser(user.getUsername());
vmi.setUpdatedate(new Date().toString());
System.out.println("vmi getFid=="+vmi.getFid());
System.out.println("vmi getFaddress=="+vmi.getFaddress());
System.out.println("vmi getFchargeman=="+vmi.getFchargeman());
System.out.println("vmi getFcustcode=="+vmi.getFcustcode());
System.out.println("vmi getFcustsort=="+vmi.getFcustsort());
System.out.println("vmi getFinsertuser=="+vmi.getFinsertuser());
System.out.println("vmi getFremarks=="+vmi.getFremarks());
System.out.println("vmi getFstockcode=="+vmi.getFstockcode());
System.out.println("vmi getFstockname=="+vmi.getFstockname());
System.out.println("vmi getFtel=="+vmi.getFtel());
System.out.println("vmi getFupdateuser=="+vmi.getFupdateuser());
tvmistockService.saveObject(vmi);
out.print("{success:true,data:'save data success!'}");
}catch(Exception e){
e.printStackTrace();
out.print("{success:false,data:'save data fail!'}");
System.out.println(this.getClass()+" add cangdian errors!!!");
}
return null;
}
//--------------------编辑可以和查看共用,只是跳转不同-------------------------------
public String cangDianEdit()
{
System.out.println("test cangdian Edit start-----------------");
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setContentType("text/html;charset=UTF-8");
Map session = ctx.getSession();
Tuser user = (Tuser)session.get("user");
//int pageNo = start/limit+1;
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try{
vmi.setFinsertdate(new Date());
vmi.setFinsertuser(user.getUsername());
//System.out.println("vmi fid================"+vmi.getFid());
Tvmistock tvmi = tvmistockService.findById(vmi.getFid());
JSONArray array = JSONArray.fromObject(tvmi);
//System.out.println("array.toString============"+array.toString());
out.print("{success:true,totalSize:1,data:" + array.toString() + "}");
//out.print("{success:true,data:'save data success!'}");
}catch(Exception e){
e.printStackTrace();
out.print("{success:false,data:'save data fail!'}");
System.out.println(this.getClass()+" add cangdian errors!!!");
}
return null;
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}
3.CangDianAction
package com.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import net.sf.json.JSONArray;
import com.model.Tvmistock;
import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import com.service.base.ITvmistockService;
import com.util.JsonUtil;
public class CangDianAction extends ActionSupport {
// private Logger logger=Logger.getLogger(this.getClass());
private ITvmistockService tvmistockService;
private int start;
private int limit;
private Tvmistock vmi = new Tvmistock();
private String delData;
//---------------一个ext list例子方法--------------------------
//--------delData是ext传过来要删去的记录的id (18,35,46,89)
public String jsonExecute() throws Exception {
if (this.getDelData() != null && !"".equals(this.getDelData())) {
if (this.getDelData().indexOf(",") < 0) {
// this.levelService.removeLevelById(Long.parseLong(this.getDelData()));
System.out.println("del_id:" + getDelData());
} else {
String id[] = this.getDelData().split(",");
for (int i = 0; i < id.length; i++) {
System.out.println("del:" + id[i]);
//this.levelService.removeLevelById(Long.parseLong(id[i]));
}
}
}
HttpSession session = ServletActionContext.getRequest().getSession();
Object o = null;// session.getAttribute("Level_Data1");
if (o == null) {
try {
// this.levels = this.getLevelService().findAllLevels();
//session.setAttribute("Level_Data1", this.levels);
System.out.println("query database");
} catch (Exception e) {
e.printStackTrace();
}
} else {
//this.setLevels(((List<Level>) o));
}
// this.setTotalCount(this.levels.size());
//JSONArray array = JSONArray.fromObject(this.levels);
// System.out.println(this.getStart() + "---" + this.getLimit());
// this.setJsonString("{success:true,totalCount : " + this.getTotalCount() + ", list:" + array.toString() + "}");
// System.out.println(this.getJsonString());
//return super.jsonExecute();
return null;
}
public String list() throws Exception {
List stocklist = tvmistockService.getAll();
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
StringBuffer sb = new StringBuffer();
sb.append("{total:"+stocklist.size()+",rows:[");
int i=1;
for(Iterator ite = stocklist.iterator();ite.hasNext();){
Tvmistock tvmistock = (Tvmistock)ite.next();
if(i==stocklist.size()){
sb.append("{value:'"+tvmistock.getFstockcode()+"',text:'"+tvmistock.getFstockname()+"'}");
}else{
sb.append("{value:'"+tvmistock.getFstockcode()+"',text:'"+tvmistock.getFstockname()+"'},");
}
i++;
}
sb.append("]}");
out.print(sb.toString());
return null;
}
//有分页功能的list
public String listPage() {
//-------------------如果delData有值就先调用删除功能-----------------
System.out.println("deldata===================================="+getDelData());
if (this.getDelData() != null && !"".equals(this.getDelData())) {
if (this.getDelData().indexOf(",") < 0) {
// this.levelService.removeLevelById(Long.parseLong(this.getDelData()));
tvmistockService.removeById(Integer.parseInt(this.getDelData()));
System.out.println("del_id:" + getDelData());
} else {
String id[] = this.getDelData().split(",");
for (int i = 0; i < id.length; i++) {
System.out.println("del:" + id[i]);
tvmistockService.removeById(Integer.parseInt(id[i]));
//this.levelService.removeLevelById(Long.parseLong(id[i]));
}
}
this.setDelData("");//置空
}
//--------------------delete end-----------------------------
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setContentType("text/html;charset=UTF-8");
int pageNo = start/limit+1;
try{
List stocklist = tvmistockService.getAllStockByPage(pageNo, limit, "fstockcode", false);
PrintWriter out = response.getWriter();
JsonUtil ju = new JsonUtil();
StringBuffer sb = new StringBuffer();
sb.append("{totalSize:"+stocklist.size()+",data:[");
int i=1;
for(Iterator ite = stocklist.iterator();ite.hasNext();){
Tvmistock tvmistock = (Tvmistock)ite.next();
if(i==stocklist.size()){
//sb.append(ju.getJsonString4JavaPOJO(tvmistock));
sb.append("{fid:'"+tvmistock.getFid()+"',cangdiancode:'"+tvmistock.getFstockcode()+"',cangdianname:'"+tvmistock.getFstockname()+"',custname:'"+tvmistock.getFcustcode()+"',createdate:'"+tvmistock.getFinsertdate()+"',chargeman:'"+tvmistock.getFcustsort()+"',status:'"+tvmistock.getFstatus()+"'}");
}else{
sb.append("{fid:'"+tvmistock.getFid()+"',cangdiancode:'"+tvmistock.getFstockcode()+"',cangdianname:'"+tvmistock.getFstockname()+"',custname:'"+tvmistock.getFcustcode()+"',createdate:'"+tvmistock.getFinsertdate()+"',chargeman:'"+tvmistock.getFcustsort()+"',status:'"+tvmistock.getFstatus()+"'},");
//sb.append(ju.getJsonString4JavaPOJO(tvmistock)+",");
//sb.append("{value:'"+tvmistock.getFstockcode()+"',text:'"+tvmistock.getFstockname()+"'},");
}
i++;
}
sb.append("]}");
out.print(sb.toString());
System.out.print(sb.toString());
}catch(Exception e){
e.printStackTrace();
System.out.println(this.getClass()+" listPage errors!!!");
}
return null;
}
//新增倉點
public String addCangDian() {
System.out.println("-------------------add start --------------");
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.setContentType("text/html;charset=UTF-8");
//int pageNo = start/limit+1;
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try{
System.out.println("vmi getFaddress=="+vmi.getFaddress());
System.out.println("vmi getFchargeman=="+vmi.getFchargeman());
System.out.println("vmi getFcustcode=="+vmi.getFcustcode());
System.out.println("vmi getFcustsort=="+vmi.getFcustsort());
System.out.println("vmi getFinsertuser=="+vmi.getFinsertuser());
System.out.println("vmi getFremarks=="+vmi.getFremarks());
System.out.println("vmi getFstockcode=="+vmi.getFstockcode());
System.out.println("vmi getFstockname=="+vmi.getFstockname());
System.out.println("vmi getFtel=="+vmi.getFtel());
System.out.println("vmi getFupdateuser=="+vmi.getFupdateuser());
tvmistockService.saveObject(vmi);
out.print("{success:true,data:'save data success!'}");
}catch(Exception e){
e.printStackTrace();
out.print("{success:false,data:'save data fail!'}");
System.out.println(this.getClass()+" listPage errors!!!");
}
return null;
}
public ITvmistockService getTvmistockService() {
return tvmistockService;
}
public void setTvmistockService(ITvmistockService tvmistockService) {
this.tvmistockService = tvmistockService;
}
public int getStart() {
return start;
}
public void setStart(int start) {
this.start = start;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public Tvmistock getVmi() {
return vmi;
}
public String getDelData() {
return delData;
}
public void setDelData(String delData) {
this.delData = delData;
}
}
4.xwork.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1.1//EN" "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd">
<xwork>
<include file="webwork-default.xml"/>
<package name="com" extends="webwork-default">
<interceptors>
<interceptor name="auth" class="com.service.AuthenticationInterceptor"/>
<interceptor-stack name="crudStack">
<interceptor-ref name="params" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<action name="login" class="loginAction">
<result name="success">main.jsp</result>
<result name="error">index.jsp</result>
</action>
<action name="extlogin" class="extLoginAction" method="extLogin">
<result name="success">/Inventory/ext_viewport.jsp</result>
<result name="error">ext_login.jsp</result>
</action>
<action name="addcd" class="extLoginAction" method="addCangDian">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
<action name="allmenu" class="getMenuAction" method="allMenu">
<result name="success">MenuBar.jsp</result>
</action>
<action name="extmenu" class="getMenuAction" method="extMenu">
<result name="success">MenuBar.jsp</result>
</action>
<action name="userAct" class="userAction">
<interceptor-ref name="fileUploadStack"></interceptor-ref>
<result name="success">hide.jsp</result>
<result name="error">hide.jsp</result>
</action>
<!-- CaseManage -->
<action name="addCase" class="caseAction" method="addCase">
<result name="success">/admin/code_list.jsp</result>
<result name="error">/admin/code_list.jsp</result>
</action>
<action name="viewCase" class="caseAction" method="viewCase">
<result name="success">/admin/code_list.jsp</result>
</action>
<!-- -->
<!-- CodeManage -->
<action name="addCode" class="codeAction" method="addCode">
<result name="success">/admin/code_list.jsp</result>
</action>
<action name="viewCode" class="codeAction" method="viewCode">
<result name="success">/admin/code_list.jsp</result>
</action>
<action name="deleteCode" class="codeAction" method="deleteCode">
<result name="success">/admin/code_list.jsp</result>
</action>
<action name="editCode" class="codeAction" method="editCode">
<result name="success">/admin/code_edit.jsp</result>
</action>
<action name="updateCode" class="codeAction" method="updateCode">
<result name="success">/admin/code_list.jsp</result>
</action>
<!-- userSetManage -->
<action name="viewUser" class="userSetAction" method="browseUser">
<result name="success">/admin/auth_set.jsp</result>
</action>
<action name="viewUserSet" class="UserSetOperateAction" method="viewUserSet">
<result name="viewsuccess">/admin/auth_set_view.jsp</result>
<result name="editsuccess">/admin/auth_set_edit.jsp</result>
</action>
<action name="updateUserSet" class="UserSetOperateAction" method="updateUserSet">
<result name="success">/admin/auth_set.jsp?curPage=1</result>
</action>
<!--userPrivateView-->
<action name="viewUserPrivate" class="userPrivateAction" method="viewUserPrivate">
<result name="success">userprivate_view.jsp</result>
</action>
<action name="getcangdianjson" class="CangDianAction" method="list">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
<action name="cangdianList" class="CangDianAction" method="listPage">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
<action name="cangdianadd" class="cangDianAddAction" method="cangDianAdd">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
<action name="cangdianedit" class="cangDianAddAction" method="cangDianEdit">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
</package>
<package name="upload" extends="webwork-default">
<interceptors>
<interceptor name="upload" class="com.opensymphony.webwork.interceptor.FileUploadInterceptor"/>
<interceptor-stack name="uploadStack">
<interceptor-ref name="upload"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="WSStack"/>
<action name="userAct" class="userAction">
<interceptor-ref name="uploadStack"/>
<result name="success">hide.jsp</result>
<result name="error">hide.jsp</result>
</action>
<!--custom system uploadFile-->
<action name="uploadFileAct" class="uploadFileAction" method="saveUploadFile">
<interceptor-ref name="uploadStack"/>
<result name="success">uploadFileDeal.jsp</result>
<result name="error">uploadFileDeal.jsp</result>
</action>
</package>
</xwork>
5.原来还少了viewport.jsp和viewport.js文件,在另一编文章中补上
发表评论
-
ext webwork+hibernate+spring crud ssh2 viewport布局文
2009-05-15 11:05 18101.ext_viewport.jsp <%@ page ... -
ext webwork+hibernate+spring crud ssh2 记录
2009-05-15 10:44 22871.login jsp <%@ page languag ... -
ext 2.0 gridpanel实例2
2009-05-06 12:29 1504Ext.onReady(function(){ //forma ... -
ext 2.0 gridpanel实例
2009-04-24 11:04 2036var ds = new Ext.data.Store({ ... -
Ext 常用reader
2009-04-08 11:59 183910.6 常用Reader 10.6.1 ArrayRead ... -
Error: ReferenceError, response is not defined
2009-04-08 11:51 5807在用Ext+pring+hibernate+dwr时遇Erro ... -
firebug调试Ext登录框
2009-02-22 02:38 1975今天照着例子用firebug调试了一个ext的登录(fireb ...
相关推荐
在Webwork+Spring+Hibernate集成中,Spring通常作为整体架构的胶水,负责各组件的连接和协调。它可以管理Webwork的Action,通过依赖注入提供所需的Service和DAO。同时,Spring可以配置Hibernate SessionFactory,...
在提供的文档“webwork+spring+hibernate架构.doc”中,可能详细阐述了这三者如何协同工作,包括配置文件设置、依赖注入的使用、事务管理策略以及具体实例的开发步骤。而“webwork.doc”则可能专门介绍了WebWork框架...
在IT行业中,Web开发是一个非常重要的领域,而`webwork+hibernate+spring`的组合是其中一种经典的架构模式,常用于构建高效、可维护的企业级应用。这个小例子展示了如何将这三大框架整合起来,配合MySQL数据库进行...
【标题】"webwork+hibernate+spring配置包"是一个集合了三个知名Java框架的配置文件,旨在帮助开发者快速搭建基于Web的应用程序。WebWork是用于构建动态Web应用程序的一个MVC框架,Hibernate是一个强大的对象关系...
【标题】"webwork+hibernate+spring的例子"展示了如何在实际项目中整合这三大框架,即WebWork、Hibernate和Spring。这三个框架是Java Web开发中的重要组件,它们各自承担着不同的职责,共同构建了一个功能强大的应用...
【标题】:“WebWork+Spring+Hibernate网络购物系统”是一个基于特定技术栈的电商项目实现。这个系统利用了WebWork、Spring和Hibernate这三个关键的技术框架,构建了一个完整的、功能丰富的在线购物平台。WebWork...
最近在做个项目,用的是webwork+spring+hibernate,在网上看了不少webwork+spring的配制方式,大多都是老的配制方式,比如2.1.7的,webwork2.2.4新加了很多功能,和spring的配制也简单了很多,我做了一个简单的登录...
在这个实例中,你需要创建一个名为“imti”的数据库,并将提供的数据库文件导入到这个数据库中,以便WebWork+Spring+Hibernate能够访问和操作数据。 **集成过程** 集成这三个框架的过程主要包括以下几个步骤: 1. *...
webwork+spring+hibernate整合开发网络书城 第5讲
在IT行业中,Web开发是一个广泛且重要的领域,而"webwork+spring+hibernate"是一种常见的技术栈,用于构建动态、数据驱动的Web应用程序。这个技术组合涉及到三个核心组件:WebWork(一种MVC框架)、Spring(一个全面...
本源码实例只供学习。。 请一并下载webwork+spring+hibernate+freemarker (A)demo_lib 配合才能使用(此为项目的lib包。。) 请打开mark.txt参考操作
【搭建WEBWORK+SPRING+HIBERNATE框架】是一个集成三大流行开源框架的过程,用于构建高效、可扩展的企业级Web应用。以下是详细的步骤和知识点: 1. **开发环境配置**: - 使用MyEclipse 5.5.1 GA作为开发工具,它...
WebWork+Spring+Hibernate整合开发网络书城是一个典型的Java Web应用程序开发框架的集成,这三种技术分别承担了不同的职责,共同构建了一个高效、灵活的后台系统。本资源提供了一个完整的网络书城项目的第一讲,旨在...
【WebWork+Spring+Hibernate整合开发】是一种常见的Java Web应用程序架构模式,用于构建高效、可扩展的业务系统。WebWork是Action-based MVC框架,Spring是一个全面的企业级应用框架,而Hibernate则是流行的对象关系...
### 如何实现WebWork+Spring+Hibernate框架结合 随着企业级应用需求的不断增加和技术的不断发展,集成多种技术栈成为一种趋势。WebWork+Spring+Hibernate是早期比较流行的一种技术组合,它们各自解决的问题域不同,...
WebWork+Spring+Hibernate整合
在"WebWork+Spring+Hibernate整合开发demo"中,我们可以预见到以下关键点: 1. **整合配置**:整合这三个框架需要对各自的配置文件进行调整,例如在Spring的配置文件中声明Hibernate的SessionFactory,以及WebWork...
WebWork+Spring+Hibernate整合开发
【EXT+Spring+Hibernate+WebWork项目】是一个综合性的企业级应用开发实例,它整合了四个关键的技术框架:EXT、Spring、Hibernate和WebWork。这些技术的组合为构建高效、可扩展且用户友好的Web应用程序提供了强大的...