如何在ZF2模块中停止循环重定向(How to stop loop redirection in ZF2 Module)
我想要做的是在Module.php中重定向onBootstrap。 我有这个代码:
$response = $e->getResponse(); $response->setHeaders( $response->getHeaders()->addHeaderLine('Location', 'google.com')); $response->setStatusCode($response::STATUS_CODE_301); $response->sendHeaders(); exit;
此代码返回重定向循环。 有谁知道我做错了什么?
已编辑:此代码将google.com添加到baseroot后面。 如何重定向到不同的页面?
What I am trying to do is to redirect onBootstrap inside a Module.php. I have this code:
$response = $e->getResponse(); $response->setHeaders( $response->getHeaders()->addHeaderLine('Location', 'google.com')); $response->setStatusCode($response::STATUS_CODE_301); $response->sendHeaders(); exit;
This code returns redirect loop. Does anyone know what am I doing wrong?
EDITED: this code appends google.com behind the baseroot. How can I redirect to different page?
原文:https://stackoverflow.com/questions/37968522
更新时间:2024-01-28 22:01
最满意答案
您需要在您的
levels=
规范周围包装一个unique
,否则您将分配多个时间段的级别:unique(df1$gridcode)[order(unique(df1$gridcode), decreasing = TRUE)] #[1] 2 1
与
df1$gridcode[order(df1$gridcode, decreasing = TRUE)] #[1] 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
You need to wrap a
unique
around yourlevels=
specification, otherwise you are assigning the levels heaps of times:unique(df1$gridcode)[order(unique(df1$gridcode), decreasing = TRUE)] #[1] 2 1
vs.
df1$gridcode[order(df1$gridcode, decreasing = TRUE)] #[1] 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
相关问答
更多-
阅读数据后重新分配因子: x <- data.frame(x=letters[c(2,1,2)], y=1:3) x$x ## [1] b a b ## Levels: a b x$x <- factor(x$x, levels=unique(x$x)) x$x ## [1] b a b ## Levels: b a Reassign the factor after you read the data: x <- data.frame(x=letters[c(2,1,2)], y=1:3) x$x ## ...
-
使用< forcats >: iris.tr %>% mutate(Species = fct_reorder(Species, mSW)) %>% ggplot() + aes(Species, mSW, color = Species) + geom_point() Using ‹forcats›: iris.tr %>% mutate(Species = fct_reorder(Species, mSW)) %>% ggplot() + aes ...
-
R:正确重新排序因子水平 - 避免重复的因子水平?(R: correctly reorder factor levels - avoid duplicated factor levels? {ggplot2})[2021-07-04]
您需要在您的levels=规范周围包装一个unique ,否则您将分配多个时间段的级别: unique(df1$gridcode)[order(unique(df1$gridcode), decreasing = TRUE)] #[1] 2 1 与 df1$gridcode[order(df1$gridcode, decreasing = TRUE)] #[1] 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 You need to wrap a unique aroun ... -
您可以使用新行标记操作符" \n"将每个响应放在文档中的新行上。 ```{r} question <- as.factor(c(NA, NA, "response 1", "response 2", NA, "response 3")) ``` `r paste0(levels(question), " \n", collapse="")` 我在这里遇到了类似的问题 请注意,我在评论中使用了cat ,因此您可以在控制台中看到它。 在降价文档中,渲染得到了处理,因此您不需要cat you can use ...
-
只是不要将x_vline转换为一个因子: ggplot(df, aes(x=factor(x_value), y=y_value)) + geom_point(size=3, aes(colour=factor(gr)))+ facet_wrap(~gr)+ geom_vline(aes(xintercept=x_vline), linetype="dashed",colour="blue",size=0.7) Just don't convert x_vline to a fac ...
-
这是一个想法: 在您想要的任意组中切出Dimension1列,按形成的剪切变量进行分组,粘贴类别名称并计算y坐标。 我将文本和点映射到相同的颜色,但没有必要。 library(tidyverse) d1 %>% arrange(desc(Dimension1)) %>% mutate(cut = cut(Dimension1, 32), X = 0) %>% group_by(cut) %>% mutate(label = paste(Category, collaps ...
-
你将不得不明确地指定新的levels=你想要的,但有更简单的方法,而不是全部输入它们来移动它们。 例如 x <- factor(c("Yes", "No", "Other", "Yes", "No", "Other")) old.lvl<-levels(x) x<-factor(x, levels=c(sort(old.lvl[old.lvl!="Other"], decreasing=T), "Other")) x # [1] Yes No Other Yes No Other # L ...
-
假设我理解你所追求的是什么,你可以尝试订购data.frame,然后将fac1作为(顺序)级别传递。 data$fac1 <- factor(data$fac1, levels = data[order(data$fac2), "fac1"]) levels(data$fac1) > data fac1 fac2 1 jj45 md 2 yy85 md 3 ee78 md 4 ww77 md 5 dd85 av 6 jj63 av 7 ee12 av 8 ...
-
根据另一个因子的水平对ggplot轴的因子进行排序(Sorting a ggplot axis' factor according to another factor's levels)[2021-04-03]
我喜欢Ulrik的答案中的方面思想 - 这可能是最好的可视化。 要订购neighbourhood列的因子级别,最简单的方法可能是这样的: # order the data frame as desired df = df[order(df$district, df$neighbourhood), ] # set the neighbourhood levels in the order the occur in the data frame df$neighbourhood = factor(df$neig ... -
使用名称重新排序因子级别(Reorder factor levels using names)[2022-06-24]
为什么不使用基本变体来提供新的级别名称: factor(iris$Species, levels=c("virginica", "versicolor", "setosa")) 但请务必列出所有级别名称。 否则,您将得到NA值。 但是,为了完整性:如果您依赖于因子中元素的顺序,您可能应该使用ordered而不是factor 。 这只是有序水平的一个因素,或者在数学上更像是因子水平之间的关系。 看到: > ordered(1:3, levels=c('1', '3', '2')) [1] 1 2 3 Lev ...