如何使用get属性方法值在jsp中生成下拉列表

时间:2015-09-18 12:22:01

标签: java ajax jsp servlets

public String pincodeDetails(){
        System.out.println("..........................");
        if(shippingAddress.getUserid()==null || usersessionInfo.getUserID() ==null){
            return WebConstant.SESSION_EXPIRED;
        }
        Pincode pincodeObj=null;
        List<Pincode> citLlist=null;
        String stateEnteredcode=null;
        try {
            IAddressMgr iAddressMgr = (IAddressMgr) getBean("iAddressMgr");
            Long pincode=Long.parseLong(txtZip);
            pincodeObj=iAddressMgr.pincodeDetails(pincode);
            stateEnteredcode=pincodeObj.getStateCode();
            citLlist=iAddressMgr.stateWishCities("stateCode", stateEnteredcode);            
            for( Pincode pin:citLlist ){
                System.out.println("Pincode="+pin.getPincode()+", State Name="+pin.getStateName()+", state code"+pin.getStateCode()+", city="+pin.getCityName());
            }
            System.out.println(pincodeObj.getCityName());
        } catch (Exception e) {
            e.printStackTrace();
        }
        getServletRequest().setAttribute("pincodedetails", pincodeObj);
        getServletRequest().setAttribute("cities", citLlist);
        return WebConstant.SUCCESS;

这是我的动作代码,在jsp中我试图使用getAttribute方法获取值,我想创建一个下拉列表。

有人可以帮我使用此方法返回的值,以便在jsp中创建下拉列表吗?

我的jsp代码是:

    <%@page import="com.bookadda.constant.ApplicationConstant"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <%
        if (request.getAttribute("pincodedetails") == null
                || request.getAttribute("cities") == null)
            out.println(request.getAttribute("Invalid Pincode"));
    %>

<%
    if (request.getAttribute("pincodedetails") != null
            || request.getAttribute("cities") != null)

0 个答案:

没有答案