Struts2标签不起作用,EL却能用,ValueStack也能取出值

byteboy 2010-09-16 12:47:27
<%@ page language="java" import="java.util.*, com.opensymphony.xwork2.util.*" pageEncoding="utf-8"%>

<%
ValueStack vs=(ValueStack)request.getAttribute("struts.valueStack");
String str = vs.findString("helloBean.words");
out.println("From request: " + str + "<br>");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>result</title>
</head>

<body>
您所输入的文字是(Struts Tag):<s:property value="helloBean.words"/><br>
您所输入的文字是(EL):${helloBean.words} <br>
</body>
</html>

结果:
From request: 试试看!
您所输入的文字是(Struts Tag):
您所输入的文字是(EL):试试看!

查看编译出来的jsp.java文件发现struts标签依然写在了源码里,很奇怪啊,这是为什么呢?
...全文
141 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
byteboy 2010-09-16
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 sound9world 的回复:]

<%@taglib uri="/struts-tags" prefix="s"%>

导入标签库
[/Quote]
struts2.1.6早就不用导入标签库了吧,默认就可以用个应该
sound9world 2010-09-16
  • 打赏
  • 举报
回复
<%@taglib uri="/struts-tags" prefix="s"%>

导入标签库
byteboy 2010-09-16
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 sound9world 的回复:]

<%@taglib uri="/struts-tags" prefix="s"%>

导入标签库
[/Quote]
晕!是我看错了,太粗心了⊙﹏⊙b汗。。。给分给分,哈哈

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧