我将 Strust2 用于表示层。我有带有下拉列表的 struts 表单,它与 java 对象(应用程序)列表绑定。下拉显示应用程序对象列表,用户可以选择一个应用程序并提交。当在Action类中检索用户输入值时,接收值类型为“String”,我们不能直接从struts下拉中检索对象吗,以我为例“应用程序”对象
private List<Application> applicaionList = new ArrayList<Application>();
@Autowired
private ApplicationService applicationService;
private Application application;
public void loadTheForm(){
applicationList = applicationService.findAll();
}
public void submitForm(){
Document doc = new Document();
doc.setApplication(application);
}
//Getter Setters...
}
应用程序.jsp
<s:form action ="submitForm">
<s:select list ="applicationList" headerValue="---Select---" headerKey="-1" name="application"/>
</s:form>
struts.xml
<action name="submitForm" class="com.ActionSupport" method="submitForm">
<result name="success" type="tiles">/newAdminDocumentRequired.tiles</result>
</action>
当用户从下拉列表中选择值并提交时,提交的值是字符串,我们不能直接在Struts中取对象吗,如果我们不能获取选择值的对象,我们怎么能得到呢?
谢谢你,乌德西卡