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条)

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊