1

私はSpring MVCフレームワークに本当に慣れていないので、今すぐ助けが必要です。

何らかの理由で、リダイレクトが機能せず、HTTP ステータス 400 が表示され、コンソールにエラーが表示されないため、デバッグが非常に困難です。

シナリオ: 2 つのフォームがあります。最初のフォームは適切に保存され、2 番目のフォームにリダイレクトされますが、コードを繰り返して 3 番目のフォームに渡すと、http 400 エラーが発生します。最初のフォームで使用したものを複製したと確信しています。

意見:

<form:form method="POST" commandName="kiosk"
                action="${pageContext.request.contextPath}/kiosk/kiosk-initial-info-save.html">
<div align="center">
    <br /> 
    <div id="addKioskContainer">
    <div class="datagrid1" align="center" style="width: 33%;">
        <table align="center">
            <thead>
                <tr>
                    <th colspan="4" style="text-align: left;">Initial Information</th>
                </tr>
            </thead>
        </table>
    </div>
    <div>
        <table>
            <tr>
                <td>
                    <h3 align="left">&nbsp;&nbsp;You are applying for <label style="color: blue;">Restructured Loan</label> in <label style="color: blue;">Eastwood.</label></h3>
                </td>
            </tr>
        </table>
    </div>
        <div id="initialInfoContainer">
            <table cellpadding="0" cellspacing="10">
                <tr>
                    <td style="font-size: 12px;" >
                        <b>Purpose of Loan: </b>
                    </td>
                    <td>
                        <form:input path="loanPurpose" size="40"></form:input>
                    </td>
                </tr>
            </table>
        </div>
        <br />
        <div id="applicantInfoContainer">
                <div class="datagrid2" align="center" style="width: 95%;">
                    <table align="center">
                        <thead>
                            <tr>
                                <th colspan="4" style="text-align: left;">Applicant's Information</th>
                            </tr>
                        </thead>
                        <tr>
                            <td style="font-size: 12px;" >
                                <b>Last Name: </b><label style="color: red;">*</label>
                            </td>
                            <td>
                                <form:input path="appLastName" size="40"></form:input>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-size: 12px;" >
                                <b>First Name: </b><label style="color: red;">*</label>
                            </td>
                            <td>
                                <form:input path="appFirstName" size="40"></form:input>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-size: 12px;" >
                                <b>Middle Name: </b><label style="color: red;">*</label>
                            </td>
                            <td>
                                <form:input path="appMiddleName" size="40"></form:input>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-size: 12px;" >
                                <b>Birthdate: </b><label style="color: red;">*</label>
                            </td>
                            <td>
                                <form:input path="appBirthDate" size="20"></form:input>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-size: 12px;" >
                                <b>w/ Comaker: </b><label style="color: red;">*</label>
                            </td>
                            <td>
                                <form:checkbox path="withCoMaker"></form:checkbox>
                            </td>
                        </tr>
                    </table>
                </div>
        </div>
        <br />
        <div id="comakerInfoContainer">
                <div class="datagrid2" align="center" style="width: 95%;">
                    <table align="center">
                        <thead>
                            <tr>
                                <th colspan="4" style="text-align: left;">Comaker's Information</th>
                            </tr>
                        </thead>
                        <tr>
                            <td style="font-size: 12px;" >
                                <b>Last Name: </b><label style="color: red;">*</label>
                            </td>
                            <td>
                                <form:input path="comakerLastName" size="40"></form:input>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-size: 12px;" >
                                <b>First Name: </b><label style="color: red;">*</label>
                            </td>
                            <td>
                                <form:input path="comakerFirstName" size="40"></form:input>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-size: 12px;" >
                                <b>Middle Name: </b><label style="color: red;">*</label>
                            </td>
                            <td>
                                <form:input path="comakerMiddleName" size="40"></form:input>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-size: 12px;" >
                                <b>Birthdate: </b><label style="color: red;">*</label>
                            </td>
                            <td>
                                <form:input path="comakerBirthDate" size="20"></form:input>
                            </td>
                        </tr>
                    </table>
                </div>
        </div>
        <br />
        <div align="center">
            <table>
                <tr>
                    <td align="center"><input type="submit" value="Next" id="btnProceedKiosk"/></td>
                    <td></td>
                </tr>

            </table>
        </div>
    </div>
</div>

コントローラ:

 @RequestMapping( value = "/kiosk-initial-info", method = RequestMethod.GET )
public ModelAndView initialInfoKioskPage()
{
    ModelAndView modelAndView = new ModelAndView( "kiosk-initial-info" );

    modelAndView.addObject( "kiosk", new Kiosk() );

    return modelAndView;
}

@RequestMapping( value = "/kiosk-initial-info-save", method = RequestMethod.POST )
public ModelAndView saveInitialInfo( @ModelAttribute
Kiosk kiosk )
{
    ModelAndView modelAndView = new ModelAndView( "kiosk-initial-info" );

    modelAndView.addObject( "kiosk", new Kiosk() );

    return new ModelAndView( "redirect:/kiosk/kiosk-initial-info.html" );
}

モデル:

    package com.etel.kiosk.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table( name = "kioskmain" )
public class Kiosk
{

    @Id
    @GeneratedValue
    private Integer id;

    private String loanType;

    private String branch;

    private String loanPurpose;

    private String appLastName;

    private String appFirstName;

    private String appMiddleName;

    private Date appBirthDate;

    private Boolean withCoMaker;

    private String comakerLastName;

    private String comakerFirstName;

    private String comakerMiddleName;

    private Date comakerBirthDate;

    public Integer getId()
    {
        return id;
    }

    public void setId( Integer id )
    {
        this.id = id;
    }

    public String getLoanType()
    {
        return loanType;
    }

    public void setLoanType( String loanType )
    {
        this.loanType = loanType;
    }

    public String getBranch()
    {
        return branch;
    }

    public void setBranch( String branch )
    {
        this.branch = branch;
    }

    public String getLoanPurpose()
    {
        return loanPurpose;
    }

    public void setLoanPurpose( String loanPurpose )
    {
        this.loanPurpose = loanPurpose;
    }

    public String getAppLastName()
    {
        return appLastName;
    }

    public void setAppLastName( String appLastName )
    {
        this.appLastName = appLastName;
    }

    public String getAppFirstName()
    {
        return appFirstName;
    }

    public void setAppFirstName( String appFirstName )
    {
        this.appFirstName = appFirstName;
    }

    public String getAppMiddleName()
    {
        return appMiddleName;
    }

    public void setAppMiddleName( String appMiddleName )
    {
        this.appMiddleName = appMiddleName;
    }

    public Date getAppBirthDate()
    {
        return appBirthDate;
    }

    public void setAppBirthDate( Date appBirthDate )
    {
        this.appBirthDate = appBirthDate;
    }

    public Boolean getWithCoMaker()
    {
        return withCoMaker;
    }

    public void setWithCoMaker( Boolean withCoMaker )
    {
        this.withCoMaker = withCoMaker;
    }

    public String getComakerLastName()
    {
        return comakerLastName;
    }

    public void setComakerLastName( String comakerLastName )
    {
        this.comakerLastName = comakerLastName;
    }

    public String getComakerFirstName()
    {
        return comakerFirstName;
    }

    public void setComakerFirstName( String comakerFirstName )
    {
        this.comakerFirstName = comakerFirstName;
    }

    public String getComakerMiddleName()
    {
        return comakerMiddleName;
    }

    public void setComakerMiddleName( String comakerMiddleName )
    {
        this.comakerMiddleName = comakerMiddleName;
    }

    public Date getComakerBirthDate()
    {
        return comakerBirthDate;
    }

    public void setComakerBirthDate( Date comakerBirthDate )
    {
        this.comakerBirthDate = comakerBirthDate;
    }

}

DaoImpl

public void updateKiosk( Kiosk kiosk )
{
    Kiosk kioskToUpdate = getKiosk( kiosk.getId() );
    kioskToUpdate.setBranch( kiosk.getBranch() );
    kioskToUpdate.setLoanPurpose( kiosk.getLoanPurpose() );
    kioskToUpdate.setAppLastName( kiosk.getAppLastName() );
    kioskToUpdate.setAppFirstName( kiosk.getAppFirstName() );
    kioskToUpdate.setAppMiddleName( kiosk.getAppMiddleName() );
    kioskToUpdate.setAppBirthDate( kiosk.getAppBirthDate() );
    kioskToUpdate.setWithCoMaker( kiosk.getWithCoMaker() );
    kioskToUpdate.setComakerLastName( kiosk.getComakerLastName() );
    kioskToUpdate.setComakerFirstName( kiosk.getComakerFirstName() );
    kioskToUpdate.setComakerMiddleName( kiosk.getComakerMiddleName() );
    kioskToUpdate.setComakerBirthDate( kiosk.getComakerBirthDate() );
    getCurrentSession().update( kioskToUpdate );
}

あなたの答えは大いに役立ちます。ありがとう。

4

0 に答える 0