m0_68177780 2022-11-04 11:58 采纳率: 54.5%
浏览 35
已结题

request.getAttribute("type")拿不到值

哪里出现了问题吗,type==null,拿不到传输得值,已经request.getAttribute("type")了
这个是我后台代码:


public void queryBussinessSourceNameResult(HttpServletRequest request, HttpServletResponse response)throws Exception {
        
        GgCodeDto ggCodeDto = ggCodeDto(request);
        ParamUtils paramUtils = new ParamUtils(request);
        String bussinessSource = paramUtils.getParameter("bussinessSource").trim();
        String bussinessSourceName = paramUtils.getParameter("bussinessSourceName").trim();
        
        HttpSession session = request.getSession();
        GgUserDto ggUserDto = (GgUserDto)session.getAttribute("user");
        String language = ggUserDto.getCurrentLanguage();
        
        int pageNo = paramUtils.getIntParameter("pageNo", 1);
        int rowsPerPage = paramUtils.getIntParameter("rowsPerPage", AppConstants.ROWS_PERPAGE);
        Pagination pagination = new Pagination(pageNo, rowsPerPage);
    
        ggCodeDto.setCodeType("BusinessCode");
        ggCodeDto.setObject_OrderBy("displayNo");
        ggCodeDto.setCodeCode(bussinessSource);
        ggCodeDto.setCodeCName(bussinessSourceName);
        
        
        QueryCondition queryCondition = new QueryCondition(ggCodeDto,pagination);
        
        queryCondition.setConditionDto(ggCodeDto);
        queryCondition.setPagination(pagination);
        session.setAttribute("queryCondition", queryCondition);
        List result = ServiceManager.platform.getGgCodeService().find(ggCodeDto, pagination);
        PageRecord pageRecord = new PageRecord(pagination.getTotalCount(),pagination.getPageNo(), 1, pagination.getRowsPerPage(),result);

        request.setAttribute("fm", new AbstractForm(pageRecord));
        request.setAttribute("resultList", result);
    }
    

这是我前台代码:


<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/app.tld" prefix="app"%>
<html>
<head>
<link href="/common/css/Standard.css" rel="stylesheet" type="text/css">
<%

**String type = (String)request.getAttribute("type");
%>
<script language="javascript">
//点查询 
   function queryMethod(){
       fm.action="/sales/corporateQuery.do?actionType=bussinessSourceNameResult";
       fm.target="QueryResultFrame";
       fm.submit();        
   }
   //点选择
   function selectBussinessSource(){
         var count = QueryResultFrame.getElementCount('checkboxSelect'); 
      var clientIndex = 0;
      if(count == "") {
        alert("<bean:message key='message.sales.noRecord' />");
        return false;
      }
      else if(count==1){
         if(!QueryResultFrame.fm.checkboxSelect.checked==true) {
          alert("<bean:message key='message.sales.selectOne'/>");
          return false;
          } 
      } 
      else {
        var n = 0;
        for(var i=0;i<QueryResultFrame.fm.checkboxSelect.length;i++){
          if(QueryResultFrame.fm.checkboxSelect[i].checked == true){
            n = n+1;
            clientIndex = i;
            break;
          }
        }
        if(n == 0) {
          alert("<bean:message key='message.sales.selectOne'/>");
          return false;
        }
        }
        
        var bussinessSourceArray = new Array();
        bussinessSourceArray['codeCode']=QueryResultFrame.document.getElementsByName("codeCode")[clientIndex].value;
      bussinessSourceArray['codeCName']=QueryResultFrame.document.getElementsByName("codeCName")[clientIndex].value;
        
        if(evaluateMainFrameAgreement(bussinessSourceArray, window.parent.opener.fm)){    
      }else{
          window.parent.close();
      }
   }
   function evaluateMainFrameAgreement(bussinessSourceArray,mainFrameForm){
      if(bussinessSourceArray != null) {
        var type=document.getElementsByName("type")[0].value;
        alert(type);
        if(type==1){
             mainFrameForm.gsClientCorporateDtoBussinessSource.value = bussinessSourceArray['codeCode'];
             mainFrameForm.gsClientCorporateDtoBussinessSource.onchange();    
        }
      }
}
</script>
</head>
<base target="_self">
<body onload="initBody();">

<html:form action="/reins/processCodeReins.do?actionType=queryInsuranceBranchCode" target="QueryResultFrame">
<input type="text" name="type"  value="<%=request.getAttribute("type")%>">

<table id="BeforeOverViewMain" class="common" cellpadding="2" cellspacing="1"> 
    <tr><td class="formtitle" colspan="4"><bean:message key="prompt.queryBussinessSource"/></td></tr> 
    <tr>
    <td class="left"><bean:message key="GsClientCorporateDto.bussinessSource"/></td>
    <td class="right">
        <input name="bussinessSource" class="common" type="text" maxlength="18">
      </td>
    <td class="left"><bean:message key="GsClientCorporateDto.bussinessSourceName"/></td>
    <td class="right">
      <input name="bussinessSourceName" class="common" type="text">
    </td>
  </tr>
  
 </table>
<table id="buttontable" class="button" cellpadding="5" cellspacing="1">
  <tr align="center">
    <td align="center">
    
      <input type="button" class="button" value="<bean:message key="</span><span class="hljs-attr">button.find" />" onClick="queryMethod()" >
    </td>
    <TD align="center">
    
        <input type="button"  class="button" value="<bean:message key="</span><span class="hljs-attr">GuItemKindLoadingDto.selectedInd" />" onClick="selectBussinessSource();" />  
     </TD>
  </tr>
</table>
<table class="button" cellpadding="5" cellspacing="1">
   <tr>
     <td ><iframe name="QueryResultFrame" src='about:blank' style='Z-INDEX:1;WIDTH:100%;HEIGHT:410'
        marginwidth='0' marginheight='0' hspace='0' vspace='0' frameborder='0' scrolling='no'> </iframe></td>
   </tr>
</table>  
<jsp:include page="/common/StaticJavascript.jsp" />
</html:form>
</body>
</html>

  • 写回答

1条回答 默认 最新

  • 心寒丶 全栈领域优质创作者 2022-11-04 12:24
    关注

    没有 request.setAttribute("type", ); set值么?你要从request获取就要先在后端set进去

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 11月12日
  • 已采纳回答 11月4日
  • 创建了问题 11月4日

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算