我这个demo
struts2 crud 自己写的
你写的逻辑完全不对
要的话的邮箱给我、发给你

解决方案 »

  1.   

    显示迭代出的ID正确么?
    把action中查询详细的代码拿来看看
      

  2.   

    因为第一次用EClipse  规定不许用Myeclipse  所以基本都自己写的。
    [email protected]   谢谢
      

  3.   

    public class StuAction extends ActionSupport { private StudentBiz stubiz;
    private Student stu;
    private int id;
    private List<Student> stulist;

    public List<Student> getStulist() {
    return stulist;
    }
    public void setStulist(List<Student> stulist) {
    this.stulist = stulist;
    }
    public StudentBiz getStubiz() {
    return stubiz;
    }
    public void setStubiz(StudentBiz stubiz) {
    this.stubiz = stubiz;
    }
    public Student getStu() {
    return stu;
    }
    public void setStu(Student stu) {
    this.stu = stu;
    }
    public int getId() {
    return id;
    }
    public void setId(int id) {
    this.id = id;
    }
    @Override
    public String execute() throws Exception {
    try {
    stubiz.addStudent(stu);
    return SUCCESS;
    } catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
    }
    return INPUT;
    }
    public String getall()throws Exception
    {
    try {
    stulist=stubiz.getAll();
    return SUCCESS;

    } catch (Exception e) {
    e.printStackTrace();
    }
    return INPUT;
    }
    public String delStudent()throws Exception{
    try {
    stu=stubiz.getStuById(stu, id);
    stubiz.delStu(stu);
    return SUCCESS;
    } catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
    }
    return INPUT;
    }
    public String updateStu()throws Exception{
    try {
    stu=stubiz.getStuById(stu, id);
    stubiz.updateStu(stu);
    return SUCCESS;
    } catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
    }
    return INPUT;
    }
    public String getStuById()throws Exception{
    try {
    stubiz.getStuById(stu, id);
    return SUCCESS;
    } catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
    }
    return INPUT;
    }
    }
      

  4.   

    stubiz.getStuById(stu, id);
    这句前输出一下id,看看对不对
    如果没问题那就应该是sql语句的问题了
      

  5.   

    输出ID 没有什么问题,但是现在是detail.jsp文本框里面显示不出来 或者说显示有问题,不是根据ID来显示的。总是显示的同一个!!
    这我也不知道怎么传图片。。纠结。
      

  6.   

    stubiz.getStuById(stu, id);
    这句代码中传入的stu是什么作用,我不知道你查询完后有没有赋值给stu
    如果没有加上stu=stubiz.getStuById(stu, id);
      

  7.   

    leilei0932_java
    对!那个没有给赋值。谢谢,那麻烦你帮我看看那个更新有没有什么问题?
    我加了跳转ACTION 但是更新没反映,还是原来那样子!
      

  8.   

    我大概看了一下,应该是updateStu()的问题,因为你在方法里相当于什么都没有做,只是将原来的值又赋了一次,再返回全查,页面应该是跳转了吧?
    要是想修改信息的话,这个button应该改成submit,<form action="updatestu.action">
    还有stu=stubiz.getStuById(stu, id);stubiz.updateStu(stu);
    把stu=stubiz.getStuById(stu, id);这一句删除,因为你又查了一遍原来的信息,页面传递过来已经修改的值会被覆盖的
      

  9.   

    修改过了 运行  执行更新,还是一样,无任何效果。
    这是不是说明这个updateStu()方法还是没有执行?
    删除倒是没有任何问题。
      

  10.   

    传图片有几种办法。 
    第一:传一个流,用action生成。 页面用 img src="生成流的action地址"
    第二:直接用图片地址
      

  11.   

    你的Student实体类中有id这个属性么,有的话在table中加上<input name="stu.sid" type="hidden" >
    然后在方法中分别把Student的所有属性打印出来,第一看看进没进方法,第二看看值有没有正确传递过来
    还有如果以后遇到问题了,先自己考虑应该在什么地方会有问题,然后一点一点的打印,结果就自然而然的出来了