首页 新闻 会员 周边 捐助

用struts的时候发生严重错误?

0
悬赏园豆:30 [已解决问题] 解决于 2016-05-12 10:53
 1 1
 2 五月 11, 2016 5:50:00 下午 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
 3 警告: Could not find action or result: /teststruts/uped
 4 No result defined for action per.zxl.action.TestAction and result input - action - file:/D:/cmworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/teststruts/WEB-INF/classes/struts.xml:16:75
 5     at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:374)
 6     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:276)
 7     at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
 8     at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76)
 9     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
10     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
11     at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
12     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
13     at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)
14     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
15     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
16     at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)
17     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
18     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
19     at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
20     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
21     at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
22     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
23     at org.apache.struts2.interceptor.DateTextFieldInterceptor.intercept(DateTextFieldInterceptor.java:125)
24     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
25     at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
26     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
27     at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253)
28     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
29     at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
30     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
31     at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
32     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
33     at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
34     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
35     at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
36     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
37     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
38     at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:140)
39     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
40     at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
41     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
42     at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
43     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
44     at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
45     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
46     at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
47     at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:567)
48     at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
49     at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
50     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
51     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
52     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
53     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
54     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
55     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
56     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
57     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
58     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
59     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
60     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
61     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
62     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
63     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
64     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
65     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
66     at java.lang.Thread.run(Unknown Source)
错误信息
 1 <%@ page language="java" contentType="text/html; charset=utf-8"
 2     pageEncoding="utf-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <style type="text/css">
 7 table.tab {
 8     font-family: verdana, arial, sans-serif;
 9     font-size: 11px;
10     color: #333333;
11     border-width: 1px;
12     border-color: #666666;
13     border-collapse: collapse;
14 }
15 
16 table.tab td {
17     border-width: 1px;
18     padding: 8px;
19     border-style: solid;
20     border-color: #666666;
21     background-color: #dedede;
22 }
23 
24 table.tab tr {
25     border-width: 1px;
26     padding: 8px;
27     border-style: solid;
28     border-color: #666666;
29     background-color: #ffffff;
30 }
31 </style>
32 <script type="text/javascript">
33  function clcktd(form){
34      if(uname==null||name==null||age==null||sex==null||QQ==null||uname==""||name==""||age==""||sex==""||QQ=="")
35      {
36          alert("资料不能为空!");
37          return false;
38      }else{
39          return true;
40      }
41  }
42  </script>
43 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
44 <title>编辑资料</title>
45 </head>
46 <body>
47     <form action="uped" method="post" onsubmit="return check(this)">
48         <div align="left">
49             <table align="center" class="tab">
50                 <tr>
51                     <td colspan="2" align="center"><h1>用户资料</h1></td>
52                 </tr>
53                 <tr>
54                     <td>昵称:</td>
55                     <td><input type="text" name="ia.uname" value="<%=session.getAttribute("uname")%>" id="uname"/></td>
56                 </tr>
57                 <tr>
58                     <td>姓名:</td>
59                     <td><input type="text" name="ia.name" value="<%=session.getAttribute("name")%>" id="name"/></td>
60                 </tr>
61                 <tr>
62                     <td>性别:</td>
63                     <td >
64                     <% Integer a = (Integer)session.getAttribute("sex");if(a==0) {  %>
65                         <input type="radio" name="ia.sex" value="男" checked="checked"/>66                         <input type="radio" name="ia.sex" value="女"/>67                     <% } %>
68                     <% if(a==1) {  %>
69                         <input type="radio" name="ia.sex" value="男"/>70                         <input type="radio" name="ia.sex" value="女" checked="checked"/>71                     <% } %>
72                 </tr>
73                 <tr>
74                     <td>年龄:</td>
75                     <td><input type="text" name="ia.age" value="<%=session.getAttribute("age")%>" id="age"/></td>
76                 </tr>
77                 <tr>
78                     <td>邮箱:</td>
79                     <td><input type="text" name="ia.email" value="<%=session.getAttribute("email")%>" id="sex"/></td>
80                 </tr>
81                 <tr>
82                     <td>QQ:</td>
83                     <td><input type="text" name="ia.QQ" value="<%=session.getAttribute("QQ")%>" id="QQ"/></td>
84                 </tr>
85                 
86                 <tr>
87                     <td align="right" colspan="2">
88                         <button type="submit">保存</button>
89                     </td>
90                 </tr>
91             </table>
92         </div>
93     </form>
94 </body>
95 </html>
页面
 1 package per.zxl.action;
 2 
 3 import javax.servlet.http.HttpServletRequest;
 4 import javax.servlet.http.HttpSession;
 5 
 6 import org.apache.struts2.ServletActionContext;
 7 
 8 import com.opensymphony.xwork2.ActionSupport;
 9 
10 import per.zxl.dao.LogEndDao;
11 import per.zxl.dao.SelectUnameDao;
12 import per.zxl.dao.UpdataPwdDao;
13 import per.zxl.dao.UpdateUserDao;
14 import per.zxl.entity.AcctionUser;
15 import per.zxl.entity.Infa;
16 
17 public class TestAction extends ActionSupport{
18     
19     HttpServletRequest request=ServletActionContext.getRequest();
20     HttpSession session=request.getSession();
21     
22     //实体类的getset
23     AcctionUser au;
24     Infa ia;
25     
26     public Infa getIa() {
27         return ia;
28     }
29     public void setIa(Infa ia) {
30         this.ia = ia;
31     }
32     public AcctionUser getAu() {
33         return au;
34     }
35     public void setAu(AcctionUser au) {
36         this.au = au;
37     }
38 
39     //定义新密码         在下方接收新密码
40     private String newpassword;
41     //getset
42     public String getNewpassword() {
43         return newpassword;
44     }
45     public void setNewpassword(String newpassword) {
46         this.newpassword = newpassword;
47     }
48     //登录
49     public String msg(){
50         LogEndDao led=new LogEndDao();
51         boolean lgd=led.loged(au.getAccnumber(),au.getPassword());
52         SelectUnameDao sud=new SelectUnameDao();
53         if(lgd){
54             sud.select_uname((int)session.getAttribute("id"));
55             return SUCCESS;
56         }else {
57             return ERROR;
58         }
59     }
60     
61     //修改密码
62     public String upda(){
63         UpdataPwdDao upd=new UpdataPwdDao();
64         boolean upp=upd.updpwd(newpassword,(int)session.getAttribute("id"),au.getPassword());
65         if(upp){
66             session.setAttribute("password",newpassword);
67             return SUCCESS;
68         }else {
69             return ERROR;
70         }
71     }
72     
73     //修改资料
74     public String updeuser(){
75         UpdateUserDao uud=new UpdateUserDao();
76         
77         boolean uu=uud.updeuse(ia);
78 //        if(uu){
79 //            
80 //            return true;
81 //        }else {
82 //            return "error";
83 //        }
84         return "success";
85     }
86 }
action
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!DOCTYPE struts PUBLIC
 3         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
 4         "http://struts.apache.org/dtds/struts-2.0.dtd">
 5 
 6 <struts>
 7     <package name="thelog" extends="struts-default">
 8         <action name="inputlog" class="per.zxl.action.TestAction" method="msg">
 9             <result name="success">success/loged.jsp</result>
10             <result name="error">error/pwderror.jsp</result>
11         </action>
12         <action name="logpwd" class="per.zxl.action.TestAction" method="upda">
13             <result name="success">../success/loginpwd.jsp</result>
14             <result name="error">../error/nopwderror.jsp</result>
15         </action>
16         <action name="uped" class="per.zxl.action.TestAction" method="updeuser">
17             <result name="success">../success/updaend.jsp</result>
18             <result name="error">../error/nopwderror.jsp</result>
19         </action>
20     </package>
21 </struts>
struts.xml
 1 package per.zxl.dao;
 2 
 3 import java.sql.Connection;
 4 import java.sql.PreparedStatement;
 5 import java.sql.ResultSet;
 6 import java.sql.SQLException;
 7 
 8 import per.zxl.db.DbClose;
 9 import per.zxl.db.DbConn;
10 import per.zxl.entity.Infa;
11 
12 public class UpdateUserDao {
13     
14     public boolean updeuse(Infa ifa){    
15         
16         Connection conn=null;
17         PreparedStatement ps=null;
18         ResultSet rs=null;
19         
20         boolean use=false;
21         
22         conn=DbConn.getConn();
23         
24         System.out.println(ifa.getId());
25         String sql="UPDATE TB_INFA SET UNAME=?,NAME=?,SEX=?,AGE=?,EMAIL=?,QQ=? WHERE ID=?";
26         try {
27             ps=conn.prepareStatement(sql);
28             
29             ps.setString(1, ifa.getUname());
30             ps.setString(2, ifa.getName());
31             ps.setInt(3, ifa.getSex());
32             ps.setInt(4, ifa.getAge());
33             ps.setString(5, ifa.getEmail());
34             ps.setInt(6, ifa.getQQ());
35             ps.setInt(7, ifa.getId());
36             int res=ps.executeUpdate();
37             if(res>0){
38                 use=true;
39             }else {
40                 use=false;
41             }
42         } catch (SQLException e) {
43             e.printStackTrace();
44         }finally {
45             DbClose.getClose(conn, ps, rs);
46         }
47         return use;
48     }
49     
50 }
页面UpdateDao
 1 package per.zxl.dao;
 2 
 3 import java.sql.Connection;
 4 import java.sql.PreparedStatement;
 5 import java.sql.ResultSet;
 6 import java.sql.SQLException;
 7 import javax.servlet.http.HttpServletRequest;
 8 import javax.servlet.http.HttpSession;
 9 import org.apache.struts2.ServletActionContext;
10 
11 import per.zxl.db.DbClose;
12 import per.zxl.db.DbConn;
13 
14 public class SelectUnameDao {
15 
16     public static void select_uname(int id){
17         
18         HttpServletRequest request=ServletActionContext.getRequest();
19         HttpSession session=request.getSession();
20         
21         Connection conn=null;
22         PreparedStatement ps=null;
23         ResultSet rs=null;
24         
25         conn=DbConn.getConn();
26         String sql="SELECT ID,UNAME,NAME,SEX,AGE,EMAIL,QQ FROM TB_INFA WHERE ID=?";
27         try {
28             ps=conn.prepareStatement(sql);
29             ps.setInt(1, id);
30             rs=ps.executeQuery();
31             while (rs.next()) {
32                 System.out.println(rs.getInt("sex"));
33                 session.setAttribute("id", rs.getInt("id"));
34                 session.setAttribute("uname", rs.getString("uname"));
35                 session.setAttribute("name", rs.getString("name"));
36                 session.setAttribute("sex", rs.getInt("sex"));
37                 session.setAttribute("age", rs.getInt("age"));
38                 session.setAttribute("email", rs.getString("email"));
39                 session.setAttribute("QQ", rs.getInt("QQ"));
40             }
41         } catch (SQLException e) {
42             e.printStackTrace();
43         }finally {
44             DbClose.getClose(conn, ps, rs);
45         }
46     }
47 }
查询Dao

现在的情况就是!无论怎么调整都是一致报这个错误,只要已进入修改页面修改完然后点击保存就会报那个错误..超级头疼的

问题补充:
 1 package per.zxl.action;
 2 
 3 import javax.servlet.http.HttpServletRequest;
 4 import javax.servlet.http.HttpSession;
 5 
 6 import org.apache.struts2.ServletActionContext;
 7 
 8 import com.opensymphony.xwork2.ActionSupport;
 9 
10 import per.zxl.dao.LogEndDao;
11 import per.zxl.dao.SelectUnameDao;
12 import per.zxl.dao.UpdataPwdDao;
13 import per.zxl.dao.UpdateUserDao;
14 import per.zxl.entity.AcctionUser;
15 import per.zxl.entity.Infa;
16 
17 public class TestAction extends ActionSupport{
18     
19 //    public TestAction() {
20 //        System.out.println("===========");
21 //    }
22     
23     HttpServletRequest request=ServletActionContext.getRequest();
24     HttpSession session=request.getSession();
25     
26     //实体类的getset
27     AcctionUser au;
28     Infa ia;
29     
30     public Infa getIa() {
31         return ia;
32     }
33     public void setIa(Infa ia) {
34         this.ia = ia;
35     }
36     public AcctionUser getAu() {
37         return au;
38     }
39     public void setAu(AcctionUser au) {
40         this.au = au;
41     }
42 
43     //定义新密码         在下方接收新密码
44     private String newpassword;
45     //getset
46     public String getNewpassword() {
47         return newpassword;
48     }
49     public void setNewpassword(String newpassword) {
50         this.newpassword = newpassword;
51     }
52     //登录
53     public String msg(){
54         LogEndDao led=new LogEndDao();
55         boolean lgd=led.loged(au.getAccnumber(),au.getPassword());
56         SelectUnameDao sud=new SelectUnameDao();
57         if(lgd){
58             sud.select_uname((int)session.getAttribute("id"));
59             return SUCCESS;
60         }else {
61             return ERROR;
62         }
63     }
64     
65     //修改密码
66     public String upda(){
67         UpdataPwdDao upd=new UpdataPwdDao();
68         boolean upp=upd.updpwd(newpassword,(int)session.getAttribute("id"),au.getPassword());
69         if(upp){
70             session.setAttribute("password",newpassword);
71             return SUCCESS;
72         }else {
73             return ERROR;
74         }
75     }
76     
77     //修改资料
78     public String updeuser(){
79         UpdateUserDao uud=new UpdateUserDao();
80         //System.out.println("================");
81         boolean uu=uud.updeuse(ia);
82         if(uu){
83             
84             return SUCCESS;
85         }else {
86             return ERROR;
87         }
88 //        return SUCCESS;
89     }
90 }
action

最后面的   [修改资料]   跟   form action="upedd"    然后还有struts最后的配置相连

cocoyoona的主页 cocoyoona | 初学一级 | 园豆:20
提问于:2016-05-11 17:55
< >
分享
最佳答案
1

是不是要将"error"改成ERROR   并且    "success" 改成SUCCESS  感觉是这里出错了吧!

收获园豆:30
NiceCatch90 | 初学一级 |园豆:72 | 2016-05-12 09:47

我最开始的时候是这样写的

if(uu){

  return SUCCESS;

}else{

  return ERROR;

}

 

然后它报错

cocoyoona | 园豆:20 (初学一级) | 2016-05-12 09:50

@眉间剪水泛千愁: ,这是什么鬼?Struts配置文件里面没有这个返回值啊!

NiceCatch90 | 园豆:72 (初学一级) | 2016-05-12 09:54

@花落无声1991: 


//修改资料
public String updeuser(){
UpdateUserDao uud=new UpdateUserDao();
//System.out.println("================");
boolean uu=uud.updeuse(ia);
if(uu){

return SUCCESS;
}else {
return ERROR;
}
// return SUCCESS;
}

现在是这样,看着有配置了是吧?依旧报错,实在是找不到- -

cocoyoona | 园豆:20 (初学一级) | 2016-05-12 09:56

@眉间剪水泛千愁: 那我想是你updeuse(Infa ifa)方法里面的返回值有错误吧!是不是return use执行不到啊?你把你的web.xml代码发过来看一下!

NiceCatch90 | 园豆:72 (初学一级) | 2016-05-12 10:07

@花落无声1991: 好的

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
 3   <display-name>teststruts</display-name>
 4   
 5   <filter>
 6       <filter-name>struts</filter-name>
 7       <filter-class>
 8           org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
 9       </filter-class>
10   </filter>
11   <filter-mapping>
12       <filter-name>struts</filter-name>
13       <url-pattern>/*</url-pattern>
14   </filter-mapping>
15   
16   <welcome-file-list>
17     <welcome-file>index.jsp</welcome-file>
18   </welcome-file-list>
19 </web-app>
web
cocoyoona | 园豆:20 (初学一级) | 2016-05-12 10:08

@花落无声1991: 应该是可以都执行的,我那个设置的是/*诶

cocoyoona | 园豆:20 (初学一级) | 2016-05-12 10:12

@眉间剪水泛千愁: 现在没有错了??

NiceCatch90 | 园豆:72 (初学一级) | 2016-05-12 10:24

@花落无声1991: 找一个师傅帮我看了下,找到问题所在了

cocoyoona | 园豆:20 (初学一级) | 2016-05-12 10:43

@眉间剪水泛千愁: 哪里错了???求指点!

NiceCatch90 | 园豆:72 (初学一级) | 2016-05-12 10:43

@花落无声1991: int 类型的sex,它的value我设置成了"男""女',

cocoyoona | 园豆:20 (初学一级) | 2016-05-12 10:45

@花落无声1991: 还有id,sql设置了id为0他就好了- -

cocoyoona | 园豆:20 (初学一级) | 2016-05-12 10:46

@眉间剪水泛千愁: 我之前在看这个地方,但是没有看判断,只是看了ai.sex    咕~~(╯﹏╰)b   

NiceCatch90 | 园豆:72 (初学一级) | 2016-05-12 10:49

@花落无声1991: 本来是对的,小光让我把sex换成int类型.结果他又教我这么写sex....然后就悲剧啦,不过我有一点么想明白

 1 package per.zxl.dao;
 2 
 3 import java.sql.Connection;
 4 import java.sql.PreparedStatement;
 5 import java.sql.ResultSet;
 6 import java.sql.SQLException;
 7 
 8 import per.zxl.db.DbClose;
 9 import per.zxl.db.DbConn;
10 import per.zxl.entity.Infa;
11 
12 public class UpdateUserDao {
13     
14     public boolean updeuse(Infa ifa){    
15         
16         Connection conn=null;
17         PreparedStatement ps=null;
18         ResultSet rs=null;
19         
20         boolean use=false;
21         
22         conn=DbConn.getConn();
23         
24         System.out.println(ifa.getId());
25         String sql="UPDATE TB_INFA SET UNAME=?,NAME=?,SEX=?,AGE=?,EMAIL=?,QQ=? WHERE ID=?";
26         try {
27             ps=conn.prepareStatement(sql);
28             
29             ps.setString(1, ifa.getUname());
30             ps.setString(2, ifa.getName());
31             ps.setInt(3, ifa.getSex());
32             ps.setInt(4, ifa.getAge());
33             ps.setString(5, ifa.getEmail());
34             ps.setInt(6, ifa.getQQ());
35             ps.setInt(7, ifa.getId());
36             int res=ps.executeUpdate();
37             if(res>0){
38                 use=true;
39             }else {
40                 use=false;
41             }
42         } catch (SQLException e) {
43             e.printStackTrace();
44         }finally {
45             DbClose.getClose(conn, ps, rs);
46         }
47         return use;
48     }
49     
50 }
updateDao

我的updateDao为什么必须要把SQL中的Id设置为0呢?这一点没想明白我的sql中id是从1开始的,但是从1开始就找不到,把id写成0就可以找到了,你说这是为什么?

cocoyoona | 园豆:20 (初学一级) | 2016-05-12 10:51

@眉间剪水泛千愁: 哎!都是小错误造成的很长时间找不到错在哪里!因为感觉那个地方不会出错!

NiceCatch90 | 园豆:72 (初学一级) | 2016-05-12 10:51

@花落无声1991: 我SQL写的对的呀,但是为什么要从0开始?

cocoyoona | 园豆:20 (初学一级) | 2016-05-12 10:52

@眉间剪水泛千愁: 好吧我是大笨蛋..忘记把session里的id放那里指明了

cocoyoona | 园豆:20 (初学一级) | 2016-05-12 11:06
其他回答(2)
0

页面的action改成logpwd试试。即action="uped" 改为action="logpwd"

骁枫 | 园豆:223 (菜鸟二级) | 2016-05-11 18:11
0

好像是说,返回结果"input"没有定义

试着将

<action name="uped" class="per.zxl.action.TestAction" method="updeuser">
  <result name="success">../success/updaend.jsp</result>
  <result name="error">../error/nopwderror.jsp</result>
</action>

修改为

<action name="uped" class="per.zxl.action.TestAction" method="updeuser">
  <result name="success">../success/updaend.jsp</result>
  <result name="input">../success/updaend.jsp</result>
  <result name="error">../error/nopwderror.jsp</result>
</action>

 参考链接:http://stackoverflow.com/questions/5742281/no-result-defined-for-action-and-result-input

五毛钱的饼 | 园豆:517 (小虾三级) | 2016-05-11 18:24

尝试将TestAction中:

import org.apache.struts2.ServletActionContext;

改为

import com.opensymphony.xwork2.ActionContext;  

支持(0) 反对(0) 五毛钱的饼 | 园豆:517 (小虾三级) | 2016-05-12 10:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册