Java ognl.OgnlException:setProperty的目标为空。。。?

Java ognl.OgnlException:setProperty的目标为空。。。?,java,struts2,Java,Struts2,我是Struts 2的新手。我正在创建一个演示web应用程序,它允许用户在jsp上提交员工详细信息,并在下一个jsp上显示。代码如下: struts.xml <struts> <constant name="struts.custom.i18n.resources" value="ApplicationResources" /> <!-- Configuration for the default package. --> <p

我是Struts 2的新手。我正在创建一个演示web应用程序,它允许用户在jsp上提交员工详细信息,并在下一个jsp上显示。代码如下:

struts.xml

<struts>
    <constant name="struts.custom.i18n.resources" value="ApplicationResources" />

    <!-- Configuration for the default package. -->
    <package name="default" extends="struts-default" namespace="/">

        <action name="empDetails" class="com.webapp.test.action.MyAction"
            method="employeeDetails">
            <result name="success">jsp/employeeDetails.jsp</result>
        </action>

        <action name="addEmployee" class="com.webapp.test.action.MyAction"
            method="addEmployee">
            <result name="success">jsp/addEmployee.jsp</result>
        </action>
    </package>
</struts>
在上述操作类中,Employee是一个单独的模型类,具有以下属性:

String employeeID;
String name;
String department;
以下是我添加员工的JSP页面:

<%@taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Add Employee</title>
</head>
<body>
<s:form action="empDetails">
<s:textfield name="emp.employeeID" label="Employee ID"></s:textfield>
<s:textfield name="emp.name" label="Name"></s:textfield>
<s:textfield name="emp.department" label="Department"></s:textfield>
<s:submit></s:submit>
</s:form>
</body>
</html>
服务器控制台将显示以下异常:

ognl.OgnlException: target is null for setProperty(null, "department", [Ljava.lang.String;@acd4c9)
.....
ognl.OgnlException: target is null for setProperty(null, "employeeID", [Ljava.lang.String;@c5dd98)
....
ognl.OgnlException: target is null for setProperty(null, "name", [Ljava.lang.String;@5753b0)

请解释问题所在,以及如何从JSP填充employee模型对象。我不想在Action类中创建getter setter方法,也不想使用ModelDriven接口。
Employee
对象引用
emp
的getter setter方法在
MyAction
类中丢失

创建方法后问题已解决


谢谢

终于解决了。。。。MyAction类中员工引用“emp”的getter setter方法丢失。。。。
java.lang.NullPointerException
    com.webapp.test.action.MyAction.employeeDetails(MyAction.java:19)
ognl.OgnlException: target is null for setProperty(null, "department", [Ljava.lang.String;@acd4c9)
.....
ognl.OgnlException: target is null for setProperty(null, "employeeID", [Ljava.lang.String;@c5dd98)
....
ognl.OgnlException: target is null for setProperty(null, "name", [Ljava.lang.String;@5753b0)