首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

SSH初学者简单Action运行出错,多谢

2013-09-11 
SSH菜鸟简单Action运行出错,谢谢!初学SSH,简单测试程序出错,麻烦帮看看!谢谢!JSP文件:form methodPOST

SSH菜鸟简单Action运行出错,谢谢!
初学SSH,简单测试程序出错,麻烦帮看看!谢谢!

JSP文件:
 <form method="POST" name="mywebform" action="TestAction.action">
  <table width="600" border="1" cellpadding="5" cellspacing="0" align="center" id=tball style="display: block">
  <tr>  
  <td width="200" height="23" align="left">会议题名:</td>  
  <td bgcolor="#FFFFFF" onmouseout="this.bgColor = '#FFFFFF';" onmouseover="this.bgColor = '#F3F3F3'" width="400" height="23">  
  </td>
  </tr>  
  <tr>  
  <td>&nbsp;</td>  
  <td colspan="2" width="600" height="23">  
  <div align="left">  
  <input type="submit" name="Submit" value="提交" method="addtest">  
  <input type="reset" name="Submit2" value="重来">  
  </div>  
  </td>  
  </tr> 
  </table>  
 </form>  

Struts.xml

<struts>
  <package name="meeting.ssh.action" extends="struts-default">
  <!-- 资源添加 -->
<action name="TestAction" class="meeting.ssh.action.TestAction">
  <result name="SUCCESS">/test/addsuccess.jsp</result>
</action>
  </package>
</struts>


TestAction.java
package meetings.ssh.action;

import java.util.Collection;
import meetings.ssh.model.TTest1022;
import meetings.ssh.service.Ttest1022Service;
import com.opensymphony.xwork2.ActionSupport;

public class TestAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private TTest1022 ttest1022;
private Ttest1022Service ttest1022Service;

protected Collection availableItems;

private String title;

public String execute() throws Exception {
ttest1022.setTitle(ttest1022.getTitle());
ttest1022Service.save(ttest1022);
return SUCCESS;
}

public TTest1022 getTTest1022() {
return ttest1022;
}

public void setTTest1022(TTest1022 ttest1022) {
this.ttest1022 = ttest1022;
}

public Ttest1022Service getTtest1022Service() {
return ttest1022Service;
}

public void setTtest1022Service(Ttest1022Service ttest1022Service) {
this.ttest1022Service = ttest1022Service;
}

public String getTitle() {
return title;
}

public void setTitle(String ctitle) {
this.title = ctitle;
}

运行结果如下:

type Exception report
message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

java.lang.NullPointerException
meetings.ssh.action.TestAction.execute(TestAction.java:28)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)




[解决办法]


页面没有提交数据 ttest1022 应该是个null
ttest1022Service没有初始化也应该是个null
[解决办法]
学会下断点 走DEBUG模式
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行