相关疑难解决方法(0)

如何有效地迭代Java Map中的每个条目?

如果我有一个Map用Java 实现接口的对象,并希望迭代其中包含的每一对,那么通过地图的最有效方法是什么?

元素的排序是否取决于我对界面的具体映射实现?

java iteration collections dictionary

3113
推荐指数
41
解决办法
238万
查看次数

ognl.OgnlException:setProperty的target为null ...?

我是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>
Run Code Online (Sandbox Code Playgroud)

动作类

public class MyAction extends ActionSupport{

    private static final long serialVersionUID = 1L;

    private Employee emp = null; 

    public String addEmployee(){
        System.out.println("In addEmployee");
        return SUCCESS;
    }

    public String employeeDetails(){
        System.out.println("In employeeDetails");
        System.out.println("Employee ID: "+emp.getEmployeeID());
        return SUCCESS;
    }
}
Run Code Online (Sandbox Code Playgroud)

在上面的操作类中,Employee是一个单独的模型类,具有以下属性:

String employeeID;
String name;
String department; …
Run Code Online (Sandbox Code Playgroud)

java struts2

6
推荐指数
1
解决办法
3万
查看次数

标签 统计

java ×2

collections ×1

dictionary ×1

iteration ×1

struts2 ×1