简体   繁体   English

Java EE和struts以及JSP:java表单填充 - 动作bean等

[英]Java EE and struts and JSP: java form population - action bean etc

HI everyone. 嗨,大家好。

ISSUE- 问题-

Error populating nl.strohalm.cyclos.controls.cv.CvUploadForm@317bdd in /member/cvUpload javax.servlet.ServletException: BeanUtils.populate 在/ member / cvUpload javax.servlet.ServletException中填充nl.strohalm.cyclos.controls.cv.CvUploadForm@317bdd时出错:BeanUtils.populate

I am working on a opensource wep app, and trying to teach my self some skills by adding new functionality. 我正在开发一个开源的wep应用程序,并尝试通过添加新功能来教我自己一些技能。

Now The web app is called cyclos and uses - Java EE, Struts, Hibernate, JSP, Tiles-def (spring, MySql JavaScript) SETUP: controls, DAO's, services, entities etc. 现在Web应用程序被称为cyclos并使用 - Java EE,Struts,Hibernate,JSP,Tiles-def(spring,MySql JavaScript)SETUP:控件,DAO,服务,实体等。

I am trying to add new functionality such as a CV database for users to save a template and file. 我正在尝试添加新功能,例如CV数据库,以供用户保存模板和文件。

My sample JSP form looks as follows: 我的示例JSP表单如下所示:

<ssl:form method="post" action="/member/cvUpload" enctype="multipart/form-data">
<html:hidden property="id" />
<html:hidden property="owner" />
<html:hidden property="uploadDate" />

<table class="defaultTableContent" cellspacing="0" cellpadding="0">
    <tr>
        <td class="tdHeaderTable">TITLE HERE PLEASE !!!></td>

    </tr>
    <tr>
        <td colspan="2" align="left" class="tdContentTableLists">
            <table class="defaultTable">
                <tr>
                    <th class="tdHeaderContents" width="30%"> CV Upload -> needs properties copy / ref !!!</th>
                    <th class="tdHeaderContents" width="60%">&nbsp;</th>
                </tr>
                <tr>
                    <td>Notes </td>
                    <td><cyclos:richTextArea name="notes"  styleId="descriptionText"/></td>
                </tr>
                <tr>
                    <td>Address</td>
                    <td><html:text value="address" size="25" property="address" /><br>
                        <html:text value="address" size="25" property="address2" />
                        <html:text value="address" size="25" property="address3" />
                    </td>
                </tr>
                <tr>
                    <td>Phone Number</td>
                    <td><html:text value="0791 000 000" size="15" property="phoneNumber"/></td>
                </tr>
                <tr>
                    <td>Field of interest / industry</td>
                    <td><c:forEach var="industry" items="${industries}">
                            <label>
                                <html:radio property="industry" value="${industry}" styleClass="radio" /><bean:message key="cv.industries.${industry}" />
                            </label>
                            </c:forEach>
                    </td>
                </tr>
                <tr>
                    <td>CV upload</td>
                    <td><html:file property="cvContent" /></td>
                </tr>
                <tr>
                    <td>
                        <input type="submit" id="saveButton"  value="<bean:message key="global.submit"/>" align="center">
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

And my java form populated by struts or how ever looks as follows: 我的Java表单由struts或以下形式填充:

public class CvUploadForm extends BaseBindingForm {

private Long                id;
@IndexedEmbedded(depth = 4)
private Member              owner;
// private Calendar                       creationDate;
// private Member                         memberId;
private FormFile                cvContent;
private Calendar            uploadDate;
private long                memberId;

public CvUploadForm() {
}

public CvUploadForm(Long id, Member owner, FormFile cvContent, Calendar uploadDate) {
    this.id = id;
    this.owner = owner;
    this.cvContent = cvContent;
    this.uploadDate = uploadDate;

}

public Map<String, Object> getCv() {
    return values;
}
public void setCv(final Map<String, Object> map) {
    values = map;
}

public void setCv(final String key, final Object value) {
    values.put(key, value);
}

// ++ GETTERS AND SETTERS ++ // ++ GETTERS AND SETTERS ++

// ============================================= // =============================================

Now I can display my template, but my submit wont work -> and i would like to understand the issue / error shown im my output window !! 现在我可以显示我的模板,但我的提交不会工作 - >我想了解我的输出窗口显示的问题/错误! (see at top and following error ) (见顶部和后面的错误)

the next error shown is as follows : 下一个显示的错误如下:

Caused by: java.lang.IllegalArgumentException: Cannot invoke nl.strohalm.cyclos.controls.cv.CvUploadForm.setOwner - argument type mismatch 引起:java.lang.IllegalArgumentException:无法调用nl.strohalm.cyclos.controls.cv.CvUploadForm.setOwner - 参数类型不匹配

Plus couple more errors. 再加上几个错误。 (owner ov cv refers to different member table as ID - uses java enum - relationships... fetch (owner ov cv将不同的成员表称为ID - 使用java enum - relationships ... fetch

I am very grateful for any reply ! 我很感激任何回复! And mybe some clarification about the setup. 而mybe对设置有一些澄清。 I thought I onlu use the form to display bits on JSP, and the use the CV.java entity file for the maaping etc . 我以为我会使用表单在JSP上显示位,并使用CV.java实体文件进行映射等。 . so I am a little lost on getting all files and the connection right as wel las understanding the error here 所以我在获取所有文件和连接方面有点迷失,以及在这里理解错误

Thanks for any reply, if you need additional info pls let me know. 感谢您的答复,如果您需要其他信息,请告诉我。 Alex 亚历克斯

You have to see what is the type of object it attempts to pass to the setOwner method. 您必须查看它尝试传递给setOwner方法的对象类型。 It is not an object of type Member. 它不是成员类型的对象。

Use your debugger and try to see what is trying to pass. 使用调试器并尝试查看试图传递的内容。

you should precise if it's Struts 1 or struts 2. struts 1 maps proprities to actionForm ,if it's the case you should use primitive types in form action ( not objects like member) . 如果是Struts 1或struts 2,则应该精确。struts 1将属性映射到actionForm,如果是这种情况,则应在表单action中使用原始类型(而不是像member这样的对象)。 Struts 2 uses OGNL to map complex object to their specific bean. Struts 2使用OGNL将复杂对象映射到其特定的bean。

this my first post on stack over flow , i hope that it khelps you. 这是我在堆栈上发布的第一篇文章,希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM