为什么这个JSP片段会破坏我的HTML代码?

时间:2012-04-26 15:43:48

标签: html jsp tomcat spring-mvc jstl

所以我有一个jsp,根据通过spring mvc传递的变量提供提名视图和表单。现在,当用户想要填写新提名时,该视图有效。当它们查看提名以供审查时(它被标记为已禁用),它也可以工作,但它不适用于审阅者(在这种情况下称为通才)访问它。它突破了这一点:

view

注意它开始显示html代码的位置。代码显示发生在IE中,但在其他浏览器上它还没有“中断”,因为它在侧面和底部缺少表单元素。

这只发生在以下代码段中:

<div align="center">
    <c:if test="${mode==cons.GENERALIST}">
        <spring:message code="common.status"/>: <br/>
        <select name="statusId">
            <c:forEach items="${statusList}" var="status">
                <option value="${status.id}" <c:if
                        test="${status.id==currentStatusId}"> selected="selected"</c:if> >
                    <c:if test="${lang=='es'}">${status.statusSpanish}</c:if>
                    <c:if test="${lang=='en'}">${status.statusEnglish}</c:if>
                </option>
            </c:forEach>
        </select>
        <br/>
        <br/>

        <spring:message code="common.comments"/>:<br/>
        <textarea name="generalistComment" cols="50" rows="5">${currentGeneralistComment}</textarea>
        <br/>
        <br/>
        <spring:message code="common.committeeScore"/>:<br/>
        <input type="text" name="committeeScore" value="${nomination.commiteeScore}"/>
    </c:if>
</div>

完整的JSP代码在这里: *请注意我使用javascript函数访问其他表单的输入,这适用于其他提名视图,所以显然不是它 *第二个注释:这是弹簧拼贴的一部分,因此您在此处找不到htmlheadbody标签。

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<jsp:useBean id="cons" class="com.project.lmu.util.NominationMode" scope="application"/>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<script type="text/javascript">
    $(function() {
        $('.datepicker').datepicker({
            changeMonth: true,
            changeYear:  true,
            minDate:     "-50Y",
            maxDate:    new Date(),
            yearRange:  "-50",
            showOn: "button",
            buttonImage: "images/prototipo/calendar1.png",
            buttonImageOnly: true
        });
    });
</script>

<td id="content_inner">
<div id="content">

<h1><spring:message code="successNomination.lable.title"/></h1>
<br/>

<c:if test="${error==true}">

    <div class="error">
        <ul>
            <c:forEach items="${nomination.errors}" var="message">
                <li><spring:message code="${message}"/></li>
            </c:forEach>
        </ul>
    </div>
</c:if>

<form name="f" action="successSaveNomination" method="post">

<c:if test="${nomination.nominationId==null}">
    <input type="hidden" name="nominationId" value="0"/>
</c:if>
<c:if test="${nomination.nominationId!=null}">
    <input type="hidden" name="nominationId" value="${nomination.nominationId}"/>
</c:if>

<input type="hidden" name="nomineeId" value="${nominee.id}"/>
<input type="hidden" name="mode" value="${mode}"/>

<table border="0" cellpadding="0" cellspacing="5" width="100%">
    <tr>
        <td valign="top" width="150px"><b><spring:message code="successNomination.lable.subtitle1"/>: </b></td>
        <td>
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td>${nominee.firstName} ${nominee.middleName} ${nominee.lastName}</td>
                </tr>
                <tr>
                    <td><i>${nominee.jobTitle} - ${nominee.department.description} - ${nominee.id}</i></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td><b><spring:message code="successNomination.lable.subtitle4"/>: </b></td>
        <td>
            <select name="periodId"
                    <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled" </c:if> >
                <c:forEach items="${periods}" var="period">
                    <option value="${period.id}"
                            <c:if test="${period.id==nomination.periodId}">selected="selected"</c:if>>&nbsp; &nbsp;
                        &nbsp; &nbsp;${period.periodDescription}</option>
                </c:forEach>
            </select>
        </td>
    </tr>
</table>

<br/>

<table width="100%">
<tr>
    <th class="green"><spring:message code="successNomination.label.requirements.title1"/></th>
    <th width="50%" class="green"><spring:message code="successNomination.label.requirements.title2"/></th>
</tr>
<tr>
    <td class="gborder" valign="middle">
        <p><spring:message code="successNomination.label.requirements1"/></p>

        <p>
            <spring:message code="successNomination.label.requirements2"/>:
            <input type="text" class="points" disabled="disabled"
                   value="<fmt:formatDate type='date' pattern='MM/dd/yyyy' value='${nominee.hireDate}' />"/>
        </p>
    </td>
    <td class="gborder">
        <p class="centered">
            <textarea cols="40" rows="6" name="hireComments" <c:if
                    test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}"> disabled="disabled" </c:if>>${nomination.hireComments}</textarea>
        </p>
    </td>
</tr>
<tr>
    <td class="gborder"><p><spring:message code="successNomination.label.requirements3"/><br/>
        <a href="#footnote" class="required"><spring:message code="successNomination.lable.instructions1"/> </a></p>

        <table>
            <tr style="padding:3em;">
                <td><spring:message code="successNomination.label.requirements4"/>:</td>
                <td><input type="text" class="points" name="evaluationPoints1"
                           value="${nomination.evaluationPoints1}"
                           <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if> />
                </td>
                <td><spring:message code="successNomination.label.requirements5"/>:</td>
                <td><input type="text" class="points datepicker" name="evaluationYear1"
                           value="${nomination.evaluationYear1}"
                           <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if>
                           readonly="readonly"/>
                </td>

            </tr>
            <tr>
                <td><spring:message code="successNomination.label.requirements4"/>:</td>
                <td><input type="text" class="points" name="evaluationPoints2"
                           value="${nomination.evaluationPoints2}"
                           <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if> />
                </td>
                <td><spring:message code="successNomination.label.requirements5"/>:</td>
                <td><input type="text" class="points datepicker" name="evaluationYear2"
                           value="${nomination.evaluationYear2}"
                           <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if>
                           readonly="readonly"/>
                </td>
            </tr>
        </table>
    </td>
    <td class="gborder">
        <p class="centered">
            <textarea cols="40" rows="6" name="evaluationComments"
                    <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}"> disabled="disabled" </c:if>>${nomination.evaluationComments}</textarea>
        </p>
    </td>
</tr>
<tr>
    <td class="gborder"><p><spring:message code="successNomination.label.requirements6"/></p>

        <table>
            <tr>
                <td><spring:message code="successNomination.label.requirements7"/>:</td>
                <td>
                    <input type="text" class="points datepicker" name="promotionDate1"
                           <c:if test="${nomination.promotionDate1 != null}">value="${nomination.promotionDate1}"</c:if>
                           <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if>
                           readonly="readonly"/>
                </td>
            </tr>
            <tr>
                <td><spring:message code="successNomination.label.requirements7"/>:</td>
                <td>
                    <input type="text" class="points datepicker" name="promotionDate2"
                           <c:if test="${nomination.promotionDate2 != null}">value="${nomination.promotionDate2}"</c:if>
                           <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if>
                           readonly="readonly"/>
                </td>
            </tr>
            <tr>
                <td><spring:message code="successNomination.label.requirements7"/>:</td>
                <td>
                    <input type="text" class="points datepicker" name="promotionDate3"
                           <c:if test="${nomination.promotionDate3 != null}">value="${nomination.promotionDate3}"</c:if>
                           <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if>
                           readonly="readonly"/>
                </td>
            </tr>
            <tr>
                <td><spring:message code="successNomination.label.requirements7"/>:</td>
                <td>
                    <input type="text" class="points datepicker" name="promotionDate4"
                           <c:if test="${nomination.promotionDate4 != null}">value="${nomination.promotionDate4}"</c:if>
                           <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if>
                           readonly="readonly"/>
                </td>
            </tr>
        </table>
    </td>
    <td class="gborder">
        <p class="centered">
            <textarea cols="40" rows="6" name="promotionComments"
                    <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}"> disabled="disabled" </c:if>>${nomination.promotionComments}</textarea>
        </p>
    </td>
</tr>
<tr>
    <td class="gborder">
        <p>
            <spring:message code="successNomination.label.requirements8"/><br/>
            <a href="#footnote" class="required"><spring:message code="successNomination.lable.instructions1"/></a>
        </p>

        <p>

            <input type="radio" name="extraContribution" value="1"
                   <c:if test="${nomination.extraContribution == true}">checked="checked"</c:if>
                   <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if>
                   onclick="activateContributionsField(document.f)"/>
            <spring:message code="successNomination.label.requirements9"/> &nbsp;
            <input type="radio" name="extraContribution" value="0"
                   <c:if test="${nomination.extraContribution == false}">checked="checked"</c:if>
                   <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if>
                   onclick="activateContributionsField(document.f)"/>
            <spring:message code="successNomination.label.requirements10"/><br/>
            <spring:message code="successNomination.label.requirements11"/>:
            <input type="text" class="points" name="extraContributionPoints"
                   value="${nomination.extraContributionPoints}"
                   <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST || nomination.extraContribution!=true}">disabled="disabled"</c:if> />
        </p>
    </td>
    <td class="gborder">
        <p class="centered">
            <textarea cols="40" rows="6" name="extraComments"
                    <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}"> disabled="disabled" </c:if>>${nomination.extraComments}</textarea>
        </p>
    </td>
</tr>
<tr>
    <td class="gborder">
        <p><spring:message code="successNomination.label.requirements12"/><br/>
            <a href="#footnote" class="required"><spring:message code="successNomination.lable.instructions1"/></a>
        </p>

        <p>
            <input type="radio" name="companyPolicy" value="1"
                   <c:if test="${nomination.companyPolicy == true}">checked="checked"</c:if>
                   <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if> />
            <spring:message code="successNomination.label.requirements9"/> &nbsp;
            <input type="radio" name="companyPolicy" value="0"
                   <c:if test="${nomination.companyPolicy == false}">checked="checked"</c:if>
                   <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if> />
            <spring:message code="successNomination.label.requirements10"/>
        </p>
    </td>
    <td class="gborder">
        <p class="centered">
            <textarea cols="40" rows="6" name="companyPolicyComments"
                    <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}"> disabled="disabled" </c:if>>${nomination.companyPolicyComments}</textarea>
        </p>
    </td>
</tr>
<tr>
    <td class="gborder">
        <p>
            <spring:message code="successNomination.label.requirements13"/><br/>
            <a href="#footnote" class="required"><spring:message code="successNomination.lable.instructions1"/></a>
        </p>

        <p>
            <spring:message code="successNomination.label.requirements14"/>:
            <input type="radio" value="1" name="evaluationAttendancePolicy1"
                   <c:if test="${nomination.evaluationAttendancePolicy1 == true}">checked="checked"</c:if>
                   <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if> />
            <spring:message code="successNomination.label.requirements9"/>
            <input type="radio" value="0" name="evaluationAttendancePolicy1"
                   <c:if test="${nomination.evaluationAttendancePolicy1 == false}">checked="checked"</c:if>
                   <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if> />
            <spring:message code="successNomination.label.requirements10"/>
        </p>

        <p>
            <spring:message code="successNomination.label.requirements15"/>:
            <input type="radio" value="1" name="evaluationAttendancePolicy2"
                   <c:if test="${nomination.evaluationAttendancePolicy2 == true}">checked="checked"</c:if>
                   <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if> />
            <spring:message code="successNomination.label.requirements9"/>
            <input type="radio" value="0" name="evaluationAttendancePolicy2"
                   <c:if test="${nomination.evaluationAttendancePolicy2 == false}">checked="checked"</c:if>
                   <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}">disabled="disabled"</c:if> />
            <spring:message code="successNomination.label.requirements10"/>
        </p>
    </td>
    <td class="gborder">
        <p class="centered">
            <textarea cols="40" rows="6" name="attendanceComments"
                    <c:if test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}"> disabled="disabled" </c:if>>${nomination.attendanceComments}</textarea>
        </p>
    </td>
</tr>
</table>

<br/>

<p>
    <spring:message code="successNomination.label.requirements16"/>:
</p>

<div align="center">
    <textarea cols="50" rows="7" name="reason" <c:if
            test="${mode==cons.READ_ONLY||mode==cons.GENERALIST}"> disabled="disabled" </c:if> >${nomination.reason}</textarea>
</div>
<br/>

<div align="center">
    <c:if test="${mode==cons.GENERALIST}">
        <spring:message code="common.status"/>: <br/>
        <select name="statusId">
            <c:forEach items="${statusList}" var="status">
                <option value="${status.id}" <c:if
                        test="${status.id==currentStatusId}"> selected="selected"</c:if> >
                    <c:if test="${lang=='es'}">${status.statusSpanish}</c:if>
                    <c:if test="${lang=='en'}">${status.statusEnglish}</c:if>
                </option>
            </c:forEach>
        </select>
        <br/>
        <br/>

        <spring:message code="common.comments"/>:<br/>
        <textarea name="generalistComment" cols="50" rows="5">${currentGeneralistComment}</textarea>
        <br/>
        <br/>
        <spring:message code="common.committeeScore"/>:<br/>
        <input type="text" name="committeeScore" value="${nomination.commiteeScore}"/>
    </c:if>
</div>


<div id="bottommenu">
    <c:if test="${(mode==cons.NEW||mode==cons.EDIT)}">
        <input type="submit" value="<spring:message code="common.send"/>"/>
    </c:if>
    <c:if test="${mode==cons.GENERALIST}">
        <input type="button" value="<spring:message code="common.save"/>" onclick="generalistSuccessUpdate()"/>
    </c:if>
    <c:if test="${mode==cons.NEW}">
        <input type="reset" value="<spring:message code="common.reset"/>">
    </c:if>
    <c:if test="${mode==cons.EDIT}">
        <script type="text/javascript">var msg = "<spring:message code='nominations.confirm' javaScriptEscape='true' />";</script>
        <input type="button" value="<spring:message code="common.delete"/>" onclick="delNomination()"/>
    </c:if>
    <c:if test="${mode==cons.READ_ONLY||mode==cons.EDIT||mode==cons.GENERALIST}">
        <input type="button" value="<spring:message code="common.print"/>" onclick="printNomination()"/>
        <input type="button" value="<spring:message code="common.back"/>" onclick="history.back();"/>
    </c:if>
</div>

<div id="footnote">
    <p> * <spring:message code="successNomination.lable.instructions3"/>.<br/>
        **<spring:message code="successNomination.lable.instructions4"/>.</p>
</div>

</form>

<form name="d" action="successDeleteNomination" method="post">
    <input type="hidden" name="nominationId" value="${nomination.nominationId}"/>
</form>

<form name="p" action="successPrint" method="post">
    <input type="hidden" name="nominationId" value="${nomination.nominationId}"/>
</form>

<form name="g" action="successGenUpdate" method="post">
    <input type="hidden" name="nominationId" value="${nomination.nominationId}"/>
    <input type="hidden" name="statusId" value="${statusId}"/>
    <input type="hidden" name="generalistComment" value="${generalistComment}"/>
</form>

</div>
</td>

那究竟是什么打破了我的HTML?我知道这是片段,但我一直在寻找未封闭的标签。

0 个答案:

没有答案