错误如下:
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception java.lang.NullPointerException
org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:500)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
--------------------------------------------------------------------------------Apache Tomcat/6.0.35sum.jsp页面:
<%@ page language="java" import="java.util.*" pageEncoding="gbk" %>
<%@ taglib prefix="s" uri="/struts-tags" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>输入操作数</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
求代数和:<br/>
<s:form action="sums.action" >
<s:textfield name="operand1" label="操作数1:"/>
<s:textfield name="operand2" label="操作数2:"></s:textfield>
<s:submit value="代数和"></s:submit>
</s:form>
</body>
</html>
negative.jsp页面:
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'negative.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
代数和为负整数<h1><s:property value="sum"/></h1>
</body>
</html>
posivite.jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>显示代数和</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
代数和为负整数<h1><s:property value="sum" /></h1>
</body>
</html>FirstAction类:
package action;
import com.opensymphony.xwork2.ActionSupport;
public class FirstAction extends ActionSupport {
private int operand1;
private int operand2;
public String execute()throws Exception
{
if(getSum()>=0)
{
return "positive";
}
else
{
return "negative";
}
}
public int getOperand1()
{
return operand1;
}
public void setOperand1(int operand1)
{
System.out.println(operand1);
this.operand1=operand1;
}
public int getOperand2()
{
return operand2;
}
public void setOperand2(int operand2)
{
System.out.println(operand2);
this.operand2=operand2;
}
public int getSum()
{
return operand1+operand2;
}}struct.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<struts>
<package name="struts2" extends="struts-default" >
<action name="sums" class="action.FirstAction">
<result name="positive" >/positive.jsp</result>
<result name="negative">/negative.jsp</result>
</action>
</package>
</struts>
web.xml文件L
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping><!--
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
-->
</web-app>哪个朋友看看我哪里错了,导致出现上面错误,谢谢。
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception java.lang.NullPointerException
org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:500)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
--------------------------------------------------------------------------------Apache Tomcat/6.0.35sum.jsp页面:
<%@ page language="java" import="java.util.*" pageEncoding="gbk" %>
<%@ taglib prefix="s" uri="/struts-tags" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>输入操作数</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
求代数和:<br/>
<s:form action="sums.action" >
<s:textfield name="operand1" label="操作数1:"/>
<s:textfield name="operand2" label="操作数2:"></s:textfield>
<s:submit value="代数和"></s:submit>
</s:form>
</body>
</html>
negative.jsp页面:
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'negative.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
代数和为负整数<h1><s:property value="sum"/></h1>
</body>
</html>
posivite.jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>显示代数和</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
代数和为负整数<h1><s:property value="sum" /></h1>
</body>
</html>FirstAction类:
package action;
import com.opensymphony.xwork2.ActionSupport;
public class FirstAction extends ActionSupport {
private int operand1;
private int operand2;
public String execute()throws Exception
{
if(getSum()>=0)
{
return "positive";
}
else
{
return "negative";
}
}
public int getOperand1()
{
return operand1;
}
public void setOperand1(int operand1)
{
System.out.println(operand1);
this.operand1=operand1;
}
public int getOperand2()
{
return operand2;
}
public void setOperand2(int operand2)
{
System.out.println(operand2);
this.operand2=operand2;
}
public int getSum()
{
return operand1+operand2;
}}struct.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<struts>
<package name="struts2" extends="struts-default" >
<action name="sums" class="action.FirstAction">
<result name="positive" >/positive.jsp</result>
<result name="negative">/negative.jsp</result>
</action>
</package>
</struts>
web.xml文件L
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping><!--
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
-->
</web-app>哪个朋友看看我哪里错了,导致出现上面错误,谢谢。
解决方案 »
- 140分求解决
- myeclipse 中 database explorer 建立不了新连接
- 对于主机多IP,怎么设定IP去链接服务器
- 我以前发表的帖子,现在想看,但又忘记了URL, 我怎么才能找到我以前发过的贴呢??
- eclipse里选一个变量后,这个类里的该变量不变色了,是怎么回事。
- strut+hibernate+tomcat数据池配置问题
- 手工打成的rar压缩文件,java里面可以写程序打开么?
- validator中自定义验证规则,为什么报错找不到我自定义的验证函数??快速结贴
- 昨天参加北京招聘会上的三个问题
- 请问我的Servlet文件应该放在那里才能执行操作呀
- java高级软件工程师面试题
- struts文件下载问题
去找找root cause吧,那里面才有最原始错误的位置和行数。