请求路径为: http://localhost:8080/SKPlatfrom/toEditCategory.action?category.id=1=========================================================================================
package com.sk.systemInfo.action;import java.util.Date;
import java.util.Map;import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.sk.systemInfo.domain.Category;
import com.sk.systemInfo.domain.SystemUser;
import com.sk.systemInfo.service.CategoryService;public class CategoryAction extends ActionSupport implements Action {
/**注入categoryService*/
private CategoryService categoryService;
public CategoryService getCategoryService() {
return categoryService;
} public void setCategoryService(CategoryService categoryService) {
this.categoryService = categoryService;
}
private Category category;
public Category getCategory() {
return category;
} public void setCategory(Category category) {
this.category = category;
}
public String toEdit() {
//1.根据请求的编号查询类别信息
category = categoryService.findById(category.getId());
//2.获取session
Map session = ActionContext.getContext().getSession();
//3.保存到session
session.put("category", category);
return "toEdit";
}
}
==========================================================================================================
package com.sk.systemInfo.domain;import java.sql.Timestamp;
import java.util.Date;/**
* Category entity. @author MyEclipse Persistence Tools
*/public class Category implements java.io.Serializable { // Fields
//org.extremecomponents.table.cell.FilterDroplistCell
private Integer id;
private String type1;
private String type2;
private String type3;
private String flag;
private String crtuser;
private Date crtdate;
private String upduser;
private Date upddate; // Constructors /** default constructor */
public Category() {
} /** full constructor */
public Category(String type1, String type2, String type3, String flag,
String crtuser, Timestamp crtdate, String upduser, Timestamp upddate) {
this.type1 = type1;
this.type2 = type2;
this.type3 = type3;
this.flag = flag;
this.crtuser = crtuser;
this.crtdate = crtdate;
this.upduser = upduser;
this.upddate = upddate;
} // Property accessors public Integer getId() {
return this.id;
} public void setId(Integer id) {
this.id = id;
} public String getType1() {
return this.type1;
} public void setType1(String type1) {
this.type1 = type1;
} public String getType2() {
return this.type2;
} public void setType2(String type2) {
this.type2 = type2;
} public String getType3() {
return this.type3;
} public void setType3(String type3) {
this.type3 = type3;
} public String getFlag() {
return this.flag;
} public void setFlag(String flag) {
this.flag = flag.trim();
} public String getCrtuser() {
return this.crtuser;
} public void setCrtuser(String crtuser) {
this.crtuser = crtuser;
} public Date getCrtdate() {
return this.crtdate;
} public void setCrtdate(Date crtdate) {
this.crtdate = crtdate;
} public String getUpduser() {
return this.upduser;
} public void setUpduser(String upduser) {
this.upduser = upduser;
} public Date getUpddate() {
return this.upddate;
} public void setUpddate(Date upddate) {
this.upddate = upddate;
}}
==========================================================================================================请求路径为: http://localhost:8080/SKPlatfrom/toEditCategory.action?category.id=1
的时候 为什么在action中 category.getId() 为null
package com.sk.systemInfo.action;import java.util.Date;
import java.util.Map;import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.sk.systemInfo.domain.Category;
import com.sk.systemInfo.domain.SystemUser;
import com.sk.systemInfo.service.CategoryService;public class CategoryAction extends ActionSupport implements Action {
/**注入categoryService*/
private CategoryService categoryService;
public CategoryService getCategoryService() {
return categoryService;
} public void setCategoryService(CategoryService categoryService) {
this.categoryService = categoryService;
}
private Category category;
public Category getCategory() {
return category;
} public void setCategory(Category category) {
this.category = category;
}
public String toEdit() {
//1.根据请求的编号查询类别信息
category = categoryService.findById(category.getId());
//2.获取session
Map session = ActionContext.getContext().getSession();
//3.保存到session
session.put("category", category);
return "toEdit";
}
}
==========================================================================================================
package com.sk.systemInfo.domain;import java.sql.Timestamp;
import java.util.Date;/**
* Category entity. @author MyEclipse Persistence Tools
*/public class Category implements java.io.Serializable { // Fields
//org.extremecomponents.table.cell.FilterDroplistCell
private Integer id;
private String type1;
private String type2;
private String type3;
private String flag;
private String crtuser;
private Date crtdate;
private String upduser;
private Date upddate; // Constructors /** default constructor */
public Category() {
} /** full constructor */
public Category(String type1, String type2, String type3, String flag,
String crtuser, Timestamp crtdate, String upduser, Timestamp upddate) {
this.type1 = type1;
this.type2 = type2;
this.type3 = type3;
this.flag = flag;
this.crtuser = crtuser;
this.crtdate = crtdate;
this.upduser = upduser;
this.upddate = upddate;
} // Property accessors public Integer getId() {
return this.id;
} public void setId(Integer id) {
this.id = id;
} public String getType1() {
return this.type1;
} public void setType1(String type1) {
this.type1 = type1;
} public String getType2() {
return this.type2;
} public void setType2(String type2) {
this.type2 = type2;
} public String getType3() {
return this.type3;
} public void setType3(String type3) {
this.type3 = type3;
} public String getFlag() {
return this.flag;
} public void setFlag(String flag) {
this.flag = flag.trim();
} public String getCrtuser() {
return this.crtuser;
} public void setCrtuser(String crtuser) {
this.crtuser = crtuser;
} public Date getCrtdate() {
return this.crtdate;
} public void setCrtdate(Date crtdate) {
this.crtdate = crtdate;
} public String getUpduser() {
return this.upduser;
} public void setUpduser(String upduser) {
this.upduser = upduser;
} public Date getUpddate() {
return this.upddate;
} public void setUpddate(Date upddate) {
this.upddate = upddate;
}}
==========================================================================================================请求路径为: http://localhost:8080/SKPlatfrom/toEditCategory.action?category.id=1
的时候 为什么在action中 category.getId() 为null
收藏 不显示删除回复显示所有回复显示星级回复显示得分回复 怎样把Action的处理结果填充到页面的输入框内,显示后输入框仍然是可编辑的
<interceptor-ref name="checkSession"/>
<result name="success">/WEB-INF/pages/supplier/supplierList.jsp</result>
<result name="toAdd">/WEB-INF/pages/supplier/supplierAdd.jsp</result>
<result name="toEdit">/WEB-INF/pages/supplier/supplierEdit.jsp</result>
<result name="toLogin">/index2.jsp</result>
</action>
============================================================
这是struts.xml中的配置
public String intercept (ActionInvocation invocation) throws Exception {
Map session = this.getSession();
if (session.get("loginUser") == null) {
return "toLogin";
} else {
return invocation.invoke();
}
}
以上为拦截器代码
这就是产生错误的原因。