0

I've created a servlet for dropdown list. Here is the code..

DDBIRFormNo.java(servlet)

public class DDBIRFormNo extends HttpServlet {
private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            TblBIRFormNoDAO birdao = DAOFactory.getDaoManager(TblBIRFormNo.class);

            List<TblBIRFormNo> birtypelist = birdao.getAllBirFormNumber();
            request.setAttribute("birtypelist", birtypelist);
            request.getRequestDispatcher("/WEB-INF/rcmoduleIssue-eReceipt-ROR.jsp").forward(request, response);  
    }
}

I don't know if I missed something.

rcmoduleIssue-eReceipt-ROR.jsp:

<select name="bfnsCode" id="bfnsCode" class="sel" style="width: 245px; margin-left: 0;">
    <option selected="selected" value=""></option>
    <c:forEach var="bircode" items="${birtypelist}">
    <option value="${bircode.bfnsCode}">${bircode.bfnsCode}</option>
    </c:forEach>
</select>
4

1 に答える 1

0

エラーを投稿していただけますか?それは問題を見つけるのに役立ちます。同じ構造を作成してサーブレットを実装してから、ドロップダウンとその機能に値を入れようとしました。以下は私が試したコードです、 DDBIRFormNo サーブレット

public class DDBIRFormNo extends HttpServlet {

    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        List<TblBIRFormNo> birtypelist = this.getAllBirFormNumber();
        request.setAttribute("birtypelist", birtypelist);
        request.getRequestDispatcher("/WEB-INF/rcmoduleIssue-eReceipt-ROR.jsp").forward(request, response);
    }

    private List<TblBIRFormNo> getAllBirFormNumber(){
        List<TblBIRFormNo> lTblBIRFormNo = new ArrayList<TblBIRFormNo>();
        TblBIRFormNo birFormNo = new TblBIRFormNo();
        birFormNo.setBfnsCode("123");
        lTblBIRFormNo.add(birFormNo);

        birFormNo = new TblBIRFormNo();
        birFormNo.setBfnsCode("456");
        lTblBIRFormNo.add(birFormNo);

        birFormNo = new TblBIRFormNo();
        birFormNo.setBfnsCode("789");
        lTblBIRFormNo.add(birFormNo);

        birFormNo = new TblBIRFormNo();
        birFormNo.setBfnsCode("012");
        lTblBIRFormNo.add(birFormNo);
        return lTblBIRFormNo;
    }
}

TblBIRFormNo クラス

public class TblBIRFormNo {

    public String bfnsCode = null;

    /**
     * @return the bfnsCode
     */
    public String getBfnsCode() {
        return bfnsCode;
    }

    /**
     * @param bfnsCode
     *            the bfnsCode to set
     */
    public void setBfnsCode(String bfnsCode) {
        this.bfnsCode = bfnsCode;
    }
}

WEB-INF/rcmoduleIssue-eReceipt-ROR.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<select name="bfnsCode" id="bfnsCode" class="sel" style="width: 245px; margin-left: 0;">
    <option selected="selected" value=""></option>
    <c:forEach var="bircode" items="${birtypelist}">
    <option value="${bircode.bfnsCode}">${bircode.bfnsCode}</option>
    </c:forEach>
</select>
</body>
</html>

上記のサンプルはコードごとであり、正常に動作しています

于 2013-08-13T09:22:23.713 に答える