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

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日

悬赏问题

  • ¥20 非root手机,如何精准控制手机流量消耗的大小,如20M
  • ¥15 远程安装一下vasp
  • ¥15 自己做的代码上传图片时,报错
  • ¥15 Lingo线性规划模型怎么搭建
  • ¥15 关于#python#的问题,请各位专家解答!区间型正向化
  • ¥15 unity从3D升级到urp管线,打包ab包后,材质全部变紫色
  • ¥50 comsol温度场仿真无法模拟微米级激光光斑
  • ¥15 上传图片时提交的存储类型
  • ¥15 VB.NET如何绘制倾斜的椭圆
  • ¥15 arbotix没有/cmd_vel话题