データベースからリストを取得できます(ORM、つまりHibernateを使用しています)。
リスト型は私の Bean クラスです。
しかし、私が直面している問題は次のとおりです。
- SELECT BOX に取り込まれたリストにはオブジェクトがあります。値ではありません。
名前を設定する必要があります。
アクション クラス:
package com.action;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.apache.commons.io.FileUtils;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.beans.factory.annotation.Autowired;
import com.ing.aosh.service.AoshService;
import com.ing.aosh.vo.EscRprtNameVO;
import com.opensymphony.xwork2.ActionSupport;
public class FileUploadAction extends ActionSupport implements SessionAware{
Logger logger = Logger.getLogger(FileUploadAction.class.getName());
private Map session;
private String slectList;
EscRprtNameVO escNameRprtVo = new EscRprtNameVO();
private File report;
private String reportContentType;
private String reportFileName;
private List escRprtNameList = new ArrayList();
@Autowired
AoshService aoshService;
@Override
public String execute() throws Exception {
escRprtNameList = aoshService.getEscRprtNmNid();
System.out.println("escRprtNameList 2==" + ((EscRprtNameVO) escRprtNameList.get(2)).getEscRprtName());
System.out.println("escRprtNameList 4==" + ((EscRprtNameVO) escRprtNameList.get(4)).getEscRprtName());
session.put("ESCRPTDETAILS", escRprtNameList);
return "success";
}
public AoshService getAoshService() {
return aoshService;
}
public void setAoshService(AoshService aoshService) {
this.aoshService = aoshService;
}
public void setSession(Map session) {
// TODO Auto-generated method stub
this.session = session;
}
public EscRprtNameVO getEscNameRprtVo() {
return escNameRprtVo;
}
public void setEscNameRprtVo(EscRprtNameVO escNameRprtVo) {
this.escNameRprtVo = escNameRprtVo;
}
public String getSlectList() {
return slectList;
}
public void setSlectList(String slectList) {
this.slectList = slectList;
}
public List getEscRprtNameList() {
return escRprtNameList;
}
public void setEscRprtNameList(List escRprtNameList) {
this.escRprtNameList = escRprtNameList;
}
}
JSP ページ:
<s:set name="esclatnRprtName" value="#session.ESCRPTDETAILS"></s:set>
<td align="left">
<s:if test="#esclatnRprtName != null">
<s:select list="esclatnRprtName" name="slectList"/>
</s:if>
</td>
上記のJSPコードの場合、OBJECT VALUEの選択ボックスが表示されます
変更された JSP ページ
<s:set name="esclatnRprtName" value="#session.ESCRPTDETAILS"/>
<td align="left">
<s:if test="#esclatnRprtName != null">
<s:select list="esclatnRprtName" name="slectList"
listKey="esclatnRprtName['escNameRprtVo.escId']"
listValue="esclatnRprtName['escNameRprtVo.escRprtName']"/>
</s:if>
</td>
リスト自体が入力されていません..
ヘルプまたは提案のリクエスト