首页 \ 问答 \ Zend Framework - 在不同的模块中重定向到IndexController(Zend Framework - Redirecting to IndexController in different module)

Zend Framework - 在不同的模块中重定向到IndexController(Zend Framework - Redirecting to IndexController in different module)

所有,

我在Zend的mvc Framework中设置了以下项目。 在访问应用程序时,我希望用户重定向到“移动”模块,而不是转到“默认”模块中的IndexController。 我怎么做?

-billingsystem
-application
    -configs
        application.ini
    -layouts
        -scripts
            layout.phtml
    -modules
        -default
            -controllers
                IndexController.php
            -models
            -views
            Bootstrap.php
        -mobile
            -controllers
                IndexController.php
            -models
            -views
            Bootstrap.php
Bootstrap.php
-documentation
-include
-library
-logs
-public
    -design
        -css
        -images
        -js
    index.php
    .htaccess

我的index.php有以下代码:

require_once 'Zend/Application.php';
require_once 'Zend/Loader.php';


$application = new Zend_Application(
  APPLICATION_ENV,
  APPLICATION_PATH . '/configs/application.ini'
);

$application->bootstrap()->run();

All,

I have the following project setup in Zend's mvc Framework. Upon accessing the application, I want the user to redirect to "mobile" module instead of going to IndexController in "default" module. How do I do that?

-billingsystem
-application
    -configs
        application.ini
    -layouts
        -scripts
            layout.phtml
    -modules
        -default
            -controllers
                IndexController.php
            -models
            -views
            Bootstrap.php
        -mobile
            -controllers
                IndexController.php
            -models
            -views
            Bootstrap.php
Bootstrap.php
-documentation
-include
-library
-logs
-public
    -design
        -css
        -images
        -js
    index.php
    .htaccess

My index.php has the following code:

require_once 'Zend/Application.php';
require_once 'Zend/Loader.php';


$application = new Zend_Application(
  APPLICATION_ENV,
  APPLICATION_PATH . '/configs/application.ini'
);

$application->bootstrap()->run();

原文:https://stackoverflow.com/questions/5969034
更新时间:2023-09-30 07:09

最满意答案

问题2非常简单 - 你实际上并没有启动一个新线程,而只是调用run() ,它在原始线程中同步运行。 您应该调用start() ,此时异常将不会传回。

至于处理ScheduledExecutorService异常 - 如果您调用Future.get() ,它将在原始任务抛出异常时抛出ExecutionException ,从而暴露原始异常:

尝试检索由抛出异常中止的任务的结果时抛出异常。 这个异常可以使用Throwable.getCause()方法进行检查。

如果您需要在阻止未来完成的情况响应异常,则可以将您的“真实” Runnable包装到另一个已委托给原始run()方法的Runnable中,但需要使用适当的try / catch块。


Question 2 is really easy - you're not actually starting a new thread, you're just calling run(), which runs synchronously in the original thread. You should be calling start(), at which point the exception won't be propagated back.

As for handling exceptions in a ScheduledExecutorService - if you call Future.get(), it will throw ExecutionException if the original task threw an exception, exposing the original exception as the cause:

Exception thrown when attempting to retrieve the result of a task that aborted by throwing an exception. This exception can be inspected using the Throwable.getCause() method.

If you need to respond to exceptions without blocking for the future to complete, you could wrap your "real" Runnable in another one which just delegated to the original's run() method, but with an appropriate try/catch block.

相关问答

更多
  • 创建了多少个线程,并且在按执行程序调用的顺序维护顺序执行时出现问题? 我不确定我是否在理解你是否每次都要询问池线程或每次循环时分叉的线程。 因此,如果您在50次中每次创建一个新的 ExecutorService ,那么您无法分辨实际创建了多少个线程。 如果所有49个先前的作业仍在运行,则第50个作业将创建另一个作业。 如果每个作业在执行下一个作业之前完成,则只创建一个线程。 这没有考虑每个线程的期货和其他东西的数量。 如果它已经是后台线程你真的需要多个期货等吗? 没有更多细节,我似乎正确的做法是为所有50个 ...
  • 您的ExecutorService有能力运行10个线程。 但是你只提交了一个线程。 将testThread方法更改为这样。 // contains the code where public void testThread() { // add to a list List> taskList = new ArrayList>(); Callable callable1=null; for ( ...
  • 简短的回答是,在你提到的所有情况下,线程只在你开始执行任务时创建 ,即在此ExecutorService exec = Executors.newFixedThreadPool(3);之后不会创建任何线程ExecutorService exec = Executors.newFixedThreadPool(3); 执行该行,并且只有在此exec.execute(new LiftOff());之后才会创建第一个线程exec.execute(new LiftOff()); 行已执行。 为了更好地理解这一点,正如 ...
  • Thread.currentThread().interrupt(); 你不应该停止一个线程。 Thread.stop被弃用是有原因的 。 相反,你可以打断当前的线程。 Thread.currentThread().interrupt(); You shouldn't stop a thread. There is a reason Thread.stop is deprecated. Instead you can interrupt the current thread.
  • 问题2非常简单 - 你实际上并没有启动一个新线程,而只是调用run() ,它在原始线程中同步运行。 您应该调用start() ,此时异常将不会传回。 至于处理ScheduledExecutorService异常 - 如果您调用Future.get() ,它将在原始任务抛出异常时抛出ExecutionException ,从而暴露原始异常: 尝试检索由抛出异常中止的任务的结果时抛出异常。 这个异常可以使用Throwable.getCause()方法进行检查。 如果您需要在未阻止未来完成的情况下响应异常,则可以 ...
  • 我会创建2或3个threadPools,可以根据它们执行的任务进行不同的配置,如果有超过3个不同的并发操作,则会出现更大的问题。 可以在需要时(例如,通过名称)注入池,另外我将创建注释以使用AOP(例如aspectj)使用特定池/执行器执行定义的方法。 注释解析器应该可以访问所有池/执行程序,并使用注释中指定的任务提交任务。 例如: @Concurrent ("pool1") public void taskOfTypeOne() { } @Concurrent ("pool2") public void ...
  • 来自spark配置文档 : spark.executor.cores : The number of cores to use on each executor. In standalone and Mesos coarse-grained modes, setting this parameter allows an application to run multiple executors on the same worker, provided that there are enough cores ...
  • 我会说你的调查是正确的。 消费者在他们的Runnable.run实现中具有长期生存任务,因此他们每个人都永远从该执行者获得一个线程(当然,直到它死亡)。 默认的Executor是SimpleAsyncTaskExecutor中的SimpleAsyncTaskExecutor 。 这意味着任何新的消费者都会获得自己的线程,并且不会导致阻塞问题。 使用ThreadPoolTaskExecutor ,当我们的池中没有足够的线程时,我们真的会遇到问题。 有些消费者不会做他们的工作。 当我们在不同组件之间共享task ...
  • 是的,这正是因为你没有在newSingleThreadExecutor上调用shutdown,但如果你有其他正在运行的线程,他们也可能会停止应用程序退出。 要强制VM关闭(所有线程将被终止),您可以调用System.exit(0); 你把Executor服务打包成: ExecutorService service = Executors.newSingleThreadScheduledExecutor(); \\ use the service to do work \\ to shutdown the ...
  • 你是什么意思“它一次发出100条记录”? 这是否意味着单个元组包含100个CSV行? 或者在单个nextTuple()调用中发出100个元组(每个包含一个CSV行)。 对于第一种情况,Storm无法在单个元组中并行化这100行。 Storm只能向不同的执行者发送不同的元组。 对于第二种情况,Storm会将100个元组发送给不同的执行者(当然,这取决于您选择的连接模式)。 一方面评论:在一次调用nextTuple()发出多个元组被认为是不好的做法。 如果nextTuple()由于任何原因而阻塞,则nextTu ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。