zf2 module.php中实现redirect

public function onBootstrap($e)
{
    $e->getApplication()->getEventManager()->getSharedManager()->attach(‘Zend\Mvc\Controller\AbstractActionController‘, ‘dispatch‘, function($e) {
        $controller = $e->getTarget();
        if (something.....) {
            $controller->plugin(‘redirect‘)->toRoute(‘yourroute‘);
            
$controller->plugin(‘redirect‘)->toUrl($url);

} }, 100);}
For mor info visit http://framework.zend.com/manual/2.1/en/modules/zend.event-manager.event-manager.html.

时间: 2024-08-02 01:44:52

zf2 module.php中实现redirect的相关文章

maven多module项目中千万不要引入其他模块的单元测试代码

本文出处:http://blog.csdn.net/chaijunkun/article/details/35796335,转载请注明.由于本人不定期会整理相关博文,会对相应内容作出完善.因此强烈建议在原始出处查看此文. 这两天一直在整理一些旧的代码,将原来的混乱东西升级到maven管理.这其中也免不了将大项目拆分成若干个module(这里纠正一个发音,不是"猫丢",是['mɑ?d?ul],包阔我在内很多人都念错)来管理.然而为了在测试的时候图省事,在各个模块都引用的基础module中

struts2中注解redirect时传递参数中文乱码问题解决方法

试过了很多方法  tomcat 编码  .字符串转换编码 .URLEncoder  .. 但是都没解决,后来仔细看了   struts2 的redirect ,redirectAction , 加上 params={"encode","true"} 就不会有乱码了 @Action(value = "/backend/deleteApplyInfoOfAuditById", results = { @Result(name = "succ

ASP.NET web application中的redirect

在开发ASP.NET MVC web application过程中,开发上线了新系统后,需要把老系统的url redirect新系统下 其中在项目系统目录下有一个文件 301RedirectsPages.config, 内容如下: <rewriteMaps> <rewriteMap name="Redirects"> <add key="/contact-us.aspx" value="/contact-us" /&

Ajax请求中的Redirect()

页面中有一个IsLogin()方法,用以判断该请求的触发者是否登录,如果登录了,则执行查询操作,如果没有登录,则Redirect()至登录界面 页面使用了较多的Ajax请求来获取数据,而在Ajax请求中,若运行至Context.Response.Redirect()则出错. 网上的一些资料给出的解决方案是在Ajax请求中增加一个状态码,然后人为的去获取该状态码,进行重定向. IsLogin()方法需要同时处理普通请求与Ajax请求,所以,在处理之前,应当知道当前请求是否为Ajax请求. 参考了网

解决springmvc中使用redirect跳转后https变为http

方法一:配置文件修改ViewResolver的 redirectHttp10Compatible 属性,这个属性是为了兼容 http1.0协议. <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.s

struts2 -result 中的 redirect 和 redirectAction 的 区别

redirect 结果类型:与 dispatcher 结果类型相对,dispatcher 结果类型是将请求 forward(转发)到指定的 jsp 资源:而 redirect 结果类型,则意味着将请求redirect(重定向)到指定的视图资源. dispatcher 结果类型 与 redirect 结果类型的差别主要就是转发和重定向的差别:重定向会丢失所有的请求参数.请求属性. redirectAction 结果类型:当需要让一个 Action处理结束后,直接将请求重定向到另一个 Action时

node.js中的exports和module.exports

不同的编程语言都有各自的代码组织和复用的方式,如.net.php中的命名空间,python中的import,ruby中的module等,来避免命名空间污染.一直都没搞清楚node中的exports和module.exports的区别,借此搞清楚node的代码模块复用方式. 首先怎么创建node中的modules. 可以直接创建一个文件作为module,如下module.js function writeLine(){ console.log("module.js"); } export

在Android Studio中删除module

当你想在Android Studio中删除某个module时,大家习惯性的做法都是选中要删除的module,右键去找delete.但是 在Android Studio中你选中module,右键会发现没有delete,如图: 为什么会没有delete按钮,不科学啊,难道是Android Studio的bug或者设计组考虑不周.其实这边没有delete按钮主要原因是因为Android Studio对module做了一个保护机制,就是一个module你是不能随意删除的,要删除你必须得先把module从

android studio 中移除module和恢复module

一.移除Android Studio中module 在Android Studio中想要删除某个module时,在Android Studio中选中module,右键发现没有delete,如图: Android Studio对module做了一个保护机制,module是不能随意删除的,要删除必须先从module列表中移除. 移除方式有两种: 1.File菜单下Project structure...,选中你要移除的module,然后按红色的'-'按钮,这个时候仅仅是在Android Studio