我正在尝试将我的 HashMap 值存储在会话中,然后我正在使用 JSP 检索它,但我收到一条错误消息
HTTP 状态 500 - org.apache.struts2.dispatcher.SessionMap 无法转换为 java.util.HashMap
知道为什么我会收到这个错误吗?
package com.action;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.BreakIterator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.action.GetCon;
public class JanuaryAction implements SessionAware{
private String name;
Map abc = new HashMap();
public Map getAbc() {
return abc;
}
public void setAbc(Map abc) {
this.abc = abc;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public void setSession(Map abc) {
this.abc = (HashMap) abc;
}
public String execute() throws Exception{
String time=getName();
/* System.out.println(time);*/
if(time.equals("January 2013")){
abc.put(time,"'2013-01-01' AND OrderDate <= '2013-01-31'" );
}
else if(time.equals("February 2013")){
abc.put(time,"'2013-02-01' AND OrderDate <='2013-02-31'" );
}
else if(time.equals("March 2013")){
abc.put(time,"'2013-03-01' AND OrderDate <='2013-03-31'" );
}
else if(time.equals("April 2013")){
abc.put(time,"'2013-04-01' AND OrderDate <='2013-04-31'" );
}
else if(time.equals("May 2013")){
abc.put(time,"'2013-05-01' AND OrderDate <='2013-05-31'" );
}
else if(time.equals("June 2013")){
abc.put(time,"'2013-06-01' AND OrderDate <='2013-06-05'" );
}
String newtime=(String)abc.get(time);
/* System.out.println(newtime);*/
Connection con = GetCon.getCon();
Statement statement = con.createStatement();
ResultSet resultset = statement.executeQuery("SELECT MarketPlace,OrderDate, ROUND(SUM(Total),2), COUNT(*) , ROUND(ROUND(SUM(Total),2)/ COUNT(*),2) FROM vend_printed WHERE OrderDate >=" +newtime+ " GROUP BY OrderDate,MarketPlace") ;
Object value = abc.remove(time);
while(resultset.next()){
String marketplace = resultset.getString(1);
String orderdate = resultset.getString(2);
Double datamount = resultset.getDouble(3);
Integer count= resultset.getInt(4);
Double result=resultset.getDouble(5);
abc.put(0, marketplace);
abc.put(1, orderdate);
abc.put(2, datamount);
abc.put(3, count);
abc.put(4, result);}
return "success";
}}
在我的 JSP 中,我想一一显示循环值。所以我现在正在使用此代码,但它没有显示任何内容。
<s:property value="#session.0" /><br><br><br>
<s:property value="#session.1" /><br><br><br>
<s:property value="#session.2" /><br><br><br>
<s:property value="#session.3" /><br><br><br>
<s:property value="#session.4" /><br><br><br>