これが私のDAOです:
public ReportType getByName(String type) {
EntityManager em = emf.createEntityManager();
try {
ReportType rptype2 = em.find(ReportType.class, type);
return rptype2;
} catch (Exception e) {
e.printStackTrace();
em.close();
}
return null;
}
ここに私のアクションがあります:
ReportDAO dao = new ReportDAO();
List<ReportType> reportType = dao.show();
list = new ArrayList<>();
for (ReportType reportType1 : reportType) {
list.add(reportType1.getName());
}
ReportTypeDAO rpDAO = new ReportTypeDAO();
reporttype = rpDAO.getByName(type);
これが私のjspです:
<h3>Type: <s:select list="list" name="type"></s:select>
ここに私のテーブルがあります:
CREATE TABLE [dbo].[Report_Type](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](100) NULL,
提出すると文字列形式(名前)のレコードが届くのですが、このレコードIDを取得したいです。解決策はありますか?