Struts2应用程序出错

时间:2016-09-29 17:54:39

标签: struts2

当我尝试在Struts2应用程序的index.jsp中执行测试人员操作时出现以下错误

  

异常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

下面是我的struts.xml和web.xml文件。如果他们出现问题,你能否告诉我

的struts.xml

<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE struts PUBLIC
                  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                   "http://struts.apache.org/dtds/struts-2.0.dtd">
  <struts>
    <constant name="struts.devMode" value="true" />
    <package name="tester" extends="struts-default">
      <action name="tester" class="com.siebel.WebService.Tester" method="execute">
        <result name="success">/success.jsp</result>
      </action>
    </package>
  </struts>

的web.xml

<?xml version="1.0" encoding="UTF-8"?>
  <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  id="WebApp_ID" version="2.5">

    <display-name>Framework Application</display-name>
    <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <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>
  </web-app>

的index.jsp

  <%@ page language="java" contentType="text/html; charset=ISO-8859-1"  pageEncoding="ISO-8859-1"%>
  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  <%@ page import="java.sql.Connection"%>
  <%@ page import="java.sql.DriverManager"%>
  <%@ page import="java.sql.ResultSet"%>
  <%@ page import="java.sql.Statement"%>


  <%@ taglib prefix="s" uri="/struts-tags"%>
 <html>
   <head>

   </head>
   <body>
   <form action = "tester">
    <h1>Test Page</h1>
     Enter the parameter value:<input id="formParameter" type="text"             title="attribute"/>
    <button>Call WebService</button>
    </form>



     </body>
  </html>

1 个答案:

答案 0 :(得分:0)

进行以下更改并尝试:

 <form action = "tester">
<h1>Test Page</h1>
 Enter the parameter value:<input id="formParameter" type="text"             title="attribute"/>
<input type=submit value="Call WebService"/>
</form>