一个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作用域变量~!急啊~!