我试图在下拉列表中显示过去三个月。我创建了一个 JavaScript 函数并在 body 元素的Onload
属性中调用它,但我得到一个空白页面,日志中没有错误。
下面是 JSP:
<%@ page import="java.util.Collection" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/displaytag-12.tld" prefix="display"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page buffer="16kb"%>
<script type="text/javascript">
function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.appendChild(optn);
}
function OnloadPage()
{
alert('Here');
var date=new Date();
addOption(document.forms[0].month,date.getMonth(),date.getMonth());
addOption(document.forms[0].month,date.getMonth()-1,date.getMonth()-1);
addOption(document.forms[0].month,date.getMonth()-2,date.getMonth()-2);
}
</script>
<TABLE class="ReportFilter">
<TR>
<TD colspan="2"> </TD>
</TR>
</TABLE>
<body onload="OnloadPage()">
<html:form action="/zeroScoreReport.do">
<html:select property="month" name ="month" style="width:175;">
<html:option value="-1">--Please Select--</html:option>
</html:select>
<display:table name="scoreCardCol" pagesize="20" sort="list" id="data" requestURI="" class="tablelist" export="true">
<display:setProperty name="export.csv" value="false"/>
<display:setProperty name="export.xml" value="false"/>
<display:setProperty name="export.excel.filename">ZeroDefectScoreCard.xls</display:setProperty>
<display:column title="ZONE" property="zone" />
<display:column title="TM OPS NAME" sortable="true" property="tm_ops_name"></display:column>
<display:column title="RPCT BRANCH CODE" sortable="true" property="rcpt_branch_code"></display:column>
<display:column title="SUM TOT APP" sortable="true" property="sum_totapp"></display:column>
<display:column title="SUM ERROR APP" sortable="true" property="sum_error_app"></display:column>
<display:column title="SUM ZERO DEF APP" sortable="true" property="sum_zero_def_app"></display:column>
</display:table>
</html:form>
编辑:更改一些代码后,现在我在日志中收到以下错误:
ServletException in '/jsp/zero/frm_ZeroScoreCard.jsp': javax.servlet.jsp.JspException: Cannot find bean under name month
org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/zero/frm_ZeroScoreCard.jsp at line 38
尽管添加了表单bean:
private String month="";
public String getMonth() {
return month;
}
public void setMonth(String month) {
this.month = month;
}