JSP页面跳转显示数据问题!弄了几天了!求解决 我这个demostruts2 crud 自己写的你写的逻辑完全不对要的话的邮箱给我、发给你 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 显示迭代出的ID正确么?把action中查询详细的代码拿来看看 因为第一次用EClipse 规定不许用Myeclipse 所以基本都自己写的。[email protected] 谢谢 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; }} stubiz.getStuById(stu, id);这句前输出一下id,看看对不对如果没问题那就应该是sql语句的问题了 输出ID 没有什么问题,但是现在是detail.jsp文本框里面显示不出来 或者说显示有问题,不是根据ID来显示的。总是显示的同一个!!这我也不知道怎么传图片。。纠结。 stubiz.getStuById(stu, id);这句代码中传入的stu是什么作用,我不知道你查询完后有没有赋值给stu如果没有加上stu=stubiz.getStuById(stu, id); leilei0932_java对!那个没有给赋值。谢谢,那麻烦你帮我看看那个更新有没有什么问题?我加了跳转ACTION 但是更新没反映,还是原来那样子! 我大概看了一下,应该是updateStu()的问题,因为你在方法里相当于什么都没有做,只是将原来的值又赋了一次,再返回全查,页面应该是跳转了吧?要是想修改信息的话,这个button应该改成submit,<form action="updatestu.action">还有stu=stubiz.getStuById(stu, id);stubiz.updateStu(stu);把stu=stubiz.getStuById(stu, id);这一句删除,因为你又查了一遍原来的信息,页面传递过来已经修改的值会被覆盖的 修改过了 运行 执行更新,还是一样,无任何效果。这是不是说明这个updateStu()方法还是没有执行?删除倒是没有任何问题。 传图片有几种办法。 第一:传一个流,用action生成。 页面用 img src="生成流的action地址"第二:直接用图片地址 你的Student实体类中有id这个属性么,有的话在table中加上<input name="stu.sid" type="hidden" >然后在方法中分别把Student的所有属性打印出来,第一看看进没进方法,第二看看值有没有正确传递过来还有如果以后遇到问题了,先自己考虑应该在什么地方会有问题,然后一点一点的打印,结果就自然而然的出来了 Spring可以加载xml文件并打印出加载对象,但不能继续执行! jasperreport Commons FileUpload通过parseRequest得到list为空 帮看看:我的顺序图和系统结构图是不是不匹配,三层web开发 dojo中TabContainer的问题,ajax高手进!! servlet怎么样向jsp传递参数 为什么编译成功,却老是Exception in thread "main" 给学生XDJM推荐个地方,申请PHP,,jsp,asp空间,优惠!! TOMCAT虚拟目录问题 从数据库中取数据总是出错 S2Sh 小例子 问个入门级别的问题
把action中查询详细的代码拿来看看
[email protected] 谢谢
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;
}
}
这句前输出一下id,看看对不对
如果没问题那就应该是sql语句的问题了
这我也不知道怎么传图片。。纠结。
这句代码中传入的stu是什么作用,我不知道你查询完后有没有赋值给stu
如果没有加上stu=stubiz.getStuById(stu, id);
对!那个没有给赋值。谢谢,那麻烦你帮我看看那个更新有没有什么问题?
我加了跳转ACTION 但是更新没反映,还是原来那样子!
要是想修改信息的话,这个button应该改成submit,<form action="updatestu.action">
还有stu=stubiz.getStuById(stu, id);stubiz.updateStu(stu);
把stu=stubiz.getStuById(stu, id);这一句删除,因为你又查了一遍原来的信息,页面传递过来已经修改的值会被覆盖的
这是不是说明这个updateStu()方法还是没有执行?
删除倒是没有任何问题。
第一:传一个流,用action生成。 页面用 img src="生成流的action地址"
第二:直接用图片地址
然后在方法中分别把Student的所有属性打印出来,第一看看进没进方法,第二看看值有没有正确传递过来
还有如果以后遇到问题了,先自己考虑应该在什么地方会有问题,然后一点一点的打印,结果就自然而然的出来了