这里是Action中存的值:ActionContext.getContext().put("count", all);
这里是jsp中获取的值:<%=ActionContext.getContext().get("count")%>
菜鸟一枚,没用过struts2,好多年前的项目改需求,求老鸟帮忙看看
struts2还用这么麻烦吗? action中直接set get就行啊 jsp直接拿 或者 action 拿到request session啊……。
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /jsp/fxbusiness/forNlw/fx/toViewGzzpq.jsp(36,21) According to TLD, tag s:property must be empty, but is not org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:132) org.apache.jasper.compiler.Parser.parseBody(Parser.java:1603) org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:978) org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1246) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1422) org.apache.jasper.compiler.Parser.parse(Parser.java:130) org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255) org.apache.jasper.compiler.ParserController.parse(ParserController.java:103) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:185) org.apache.jasper.compiler.Compiler.__compile(Compiler.java:354) org.apache.jasper.compiler.Compiler.compile(Compiler.java) org.apache.jasper.compiler.Compiler.compile(Compiler.java:334) org.apache.jasper.compiler.Compiler.compile(Compiler.java:321) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) com.richwayAppService.fangxun.common.filter.CommonFilter.doFilter(CommonFilter.java:38) com.richwayAppService.filter.FilterUserLogin.doFilter(FilterUserLogin.java:60)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
用session取的,我怀疑是我代码有问题了,但是想想又不知道哪儿出问题
@猪喂了吗: 咋整的 代码呢
@Master_er:
Action:
List<FxGzzdt> list = fxGzzdtManage.getGzzInfoByTime(time);
int all = 0;// 用于统计所有工作组的派遣次数
int hb = 0;
int hn = 0;
int sc = 0;
int jx = 0;
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
String gzzName = list.get(i).getName();
all++;
if ("".equals(gzzName) || gzzName == null) {
all--;
continue;
}
switch (gzzName) {
case "湖北工作组":
hb++;
break;
case "湖南工作组":
hn++;
break;
case "四川工作组":
sc++;
break;
case "江西工作组":
jx++;
break;
}
}
}
// ActionContext.getContext().put("count", all);
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
session.put("count", all);
return "toViewGzzpq";
jsp:
<%@page import="com.opensymphony.xwork2.ActionContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
2017年长委共派遣工作组<s:property value="#session.count">次<br>
我把主要的代码放进来了,不知道哪儿除了问题
@Master_er: 会不会是包的问题,之前在开源中国上有人说包的版本问题,我才入职,搞得有点懵逼
@猪喂了吗: 你看他以前的代码怎么弄的啊 依葫芦画瓢啊
@Master_er: ActionContext.getContext().put("count", all);原来的就是用这个,但是他们里面放的都是list然后遍历的,我这样放个String类型的应该也没什么问题吧
@猪喂了吗: 那没问题
jsp中获取request作用域的数据不是通过ActionContext.getContext().get("xxx")的吧