action定义一个属性,get set后 对属性赋值,值是JS,页面用获取,结果不弹出JS 而是值
public class TestAction extends ActionSupport{
private ItestBiz testbiz=null;
private String show="";
public String getShow() {
return show;
}
public void setShow(String show) {
this.show = show;
}
public ItestBiz getTestbiz() {
return testbiz;
}
public void setTestbiz(ItestBiz testbiz) {
this.testbiz = testbiz;
}
public String execute()throws Exception
{
int i=testbiz.getP();
System.out.println("iiiiiiiiiiiiiiiiiiiiii--->"+i);
Person p=testbiz.getList();
System.out.println(p.getUsername());
System.out.println(p.getPassword());
System.out.println(p.getAddress());
show="<script>alert('你好吗?');</script>";
return SUCCESS;
}
}
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<constant name="struts.custom.i18n.resources" value="globalMessages">
</constant>
<constant name="struts.i18n.encoding" value="GBK"></constant>
<package name="action" extends="struts-default">
<!-- 定义拦截器 -->
<interceptors>
<!-- 定义拦截器栈 -->
<interceptor-stack name="filter1">
<!-- 引用默认的拦截器 -->
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="filter1"></default-interceptor-ref>
<action name="test" class="tttaction">
<result name="success">index.jsp</result>
</action>
</package>
index.jsp页面
<%@ taglib prefix="s" uri="/struts-tags"%>
运行工程页面显示alert('你好吗?');
实际我想要的结果是 在页面弹出一个JS对话框 内容为 你好吗? 曾经搭建的框架是可以实现弹出的,现在刚进了一家公司,自己搭建框架的时候发现这样是不行了,现在只能用EL获取这个属性可以实现弹出,请问大家有什么办法可以解决吗?
知道的请告知我,谢谢 我QQ 350101319