[b]功能需求[/b]: 通过一个下拉框来选择主题模板,将选中的值(主题模板的类名)通过Action传到另一个jsp页面(重定向),在jsp页面里根据传入的类名new出新的主页,
[b]问题[/b]: Firefox控制台显示请求发送成功,到达了请求的jsp页面,但实际页面并没跳转,任然在当前下拉框的页面,控制台显示的“load response”按钮不明白什么意思,
部分代码如下:
Firefox控制台见图:
ruling.common.HomepageChange = Ext.extend(Ext.form.ComboBox, {
fieldLabel : '选择主页模板',
editable : false,
displayField : 'classname',
valueField : 'pageclass',
emptyText : '请选择主题',
value : '默认',
width : 80,
mode : 'remote',
readonly : true,
triggerAction : 'all',
store : new Ext.data.JsonStore({ // 填充的数据
autoLoad : true,
url : contextPath + '/common/homepage/getBrowseData.html',
fields : ['pageclass','classname'],
totalProperty : 'totalCount',
root : "root"
}),
selectOnFocus : true,
initEvents : function() {
this.on('collapse', function() {
Ext.Ajax.request({
url: contextPath + '/common/homepage/gotoHome.html',
params: { classname: this.getValue() }
});
});
}
});
<package name="homepage" extends="common" namespace="/common/homepage">
<action name="getBrowseData" class="homepageAction" method="browse">
<result>/page/browseData.jsp</result>
<result name="input">/page/browseData.jsp</result>
</action>
<action name="gotoHome" class="homepageAction" method="gotoHome">
<result type="redirect">/page/login.jsp</result>
<result type="redirect" name="input">/page/main.jsp</result>
</action>
</package>
[b]问题补充:[/b]
也就是说 Ext.Ajax.request 只是 请求数据,而不能在这跳转,页面的跳转只能在回调函数中执行 比如这样
success : function(){ window.location.href =
contextPath + '/common/homepage/gotoHome.html'
},
failure : function(){}
吗
那我的参数 也是在回调函数中传递咯
我先试试 谢了
[b]问题补充:[/b]
window.location.href = contextPath + '/common/homepage/gotoHome.html?pageclass='+this.getValue();
这样是可以把值传过去,但是在目标jsp里,我要在js里拿到传入的参数,然后在new对象出来,
也就是除了传值到目标jsp后,还要把值给其中的js, 但是jsp运行在服务器端,而js是在客户端啊,这样能传过去吗
另一种方案就是 不传值,只跳转,把值放在session中,然后到目标页拿出来,
在js中能拿到session吗?
[b]问题补充:[/b]
非常感谢 两位的提示, 基本实现了
请求发送给action 然后
/page/homepage.jsp?pageclass=${pageclass}
这样就能把值传到 jsp 再想办法给js就ok了
:arrow: 谢谢