jxqn_liu 2009-02-14 12:24
浏览 236
已采纳

(急~~~!)EL表达式怎么取动态作用域变量

一个action文件:
[code="java"]
package com.struts;

import org.apache.struts.action.ActionMapping;

import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.Action;

import java.util.*;

import com.dao.*;

import com.bean.*;

public class detailsAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,

HttpServletRequest request,

HttpServletResponse response) {

detailsForm detailsForm = (detailsForm) form;

String type = request.getParameter("type");//执行类型

String id = request.getParameter("infoid");//取得的参数变化

String typediv = "";//根据这个值确定一个页面显示的内容

if (type.equals("indexnotice")) {//显示所点击的公告信息

//调用方法返回结果List

List notPGroups = DAO_ParentGroups.doSelectParentGroups

(" and Pg_Topic=(select Ct_Id from Topic where Ct_Name='产品中心')");

List notInfo = DAO_DetailsInfo.doSelectDetailsInfo(" and di_Id=" + id);//显示点击的产品详细信息

for (int i=0; i<notPGroups.size(); i++){

int j = i + 1;

Vo_ParentGroups pgroups = (Vo_ParentGroups)notPGroups.get(i);//类型转换为一个数据Bean类

int diId = pgroups.getPgId();//取得Bean的一个编号

List subGroups = DAO_Groups.doSelectGroups(" and Cg_Parent=" + diId);//根据Id查找

request.setAttribute("subgroups"+j,subGroups);//动态的设置作用域

}

request.setAttribute("notgroupslist",notPGroups);

request.setAttribute("notinfo",notInfo);

typediv = "indextopic";

}

if (type.equals("indexsovle")) {//显示所点击的解决方案

typediv = "indexsovle";

}

if (type.equals("indexnews")) {//显示所点击的新闻信息

typediv = "indexnews";

}

if (type.equals("indexproduct")) {//显示所点击的产品信息

typediv = "indexproduct";

}

if (type.equals("indexsuccase")) {//显示所点击的成功案例

typediv = "indexsuccase";

}

request.setAttribute("typediv",typediv);

return mapping.findForward("topic");

}

}

[/code]

一个JSP文件:
[code="html"]
<%@ page contentType="text/html; charset=GB2312" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

 

 

[/code]

请教各位大侠~!在JSP中怎么取得在action中动态设置的request作用域变量~!急啊~!

  • 写回答

3条回答 默认 最新

  • ChocooM 2009-02-16 09:00
    关注

    在后台可以把你的动态的作用域变量放在一个list里
    然后在jsp页面上通过EL表达式在list里循环取出判断即可

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波