gpt4 book ai didi

url - spring webflow + portal - 如何获取流定义中的url参数?

转载 作者:行者123 更新时间:2023-12-05 01:19:37 24 4
gpt4 key购买 nike

我对门户网站和 spring webflow 有点陌生,并试图将它们结合起来,以便为各种用户任务设置流程。我的问题是我需要生成指向第一个状态的直接 URL 并将子流的名称作为参数传递,以便从那里开始执行正确的子流 - 我不知道如何获取该参数。

这是我的上下文配置

<!-- Maps portlet modes to handlers -->
<bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
<property name="portletModeMap">
<map>
<entry key="view">
<bean class="com.mycompany.login.portlet.ViewFlowHandler" />
</entry>
</map>
</property>
</bean>

<!-- Enables FlowHandlers -->
<bean class="org.springframework.webflow.mvc.portlet.FlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor"/>
</bean>

<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<webflow:flow-executor id="flowExecutor">
</webflow:flow-executor>

<!-- The registry of executable flow definitions -->
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderService">
<webflow:flow-location path="classpath:flows/login-flow.xml" />
<webflow:flow-location path="classpath:flows/main-flow.xml" />
<webflow:flow-location path="classpath:flows/pwd-recovery-flow.xml" />
</webflow:flow-registry>

<webflow:flow-builder-services id="flowBuilderService" view-factory-creator="viewFactoryCreator"/>

<bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers">
<list>
<ref bean="viewResolver"/>
</list>
</property>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/flow-views/"/>
<property name="suffix" value=".jsp"/>
</bean>


<!-- beans for business logic -->
<bean id="authService"
class="com.mycompany.login.portlet.service.AuthService"
scope="prototype" />

<!-- constants -->
<bean id="flowNames" class="com.mycompany.login.portlet.Flows" scope="singleton">
<property name="loginMain"><value></value></property>
<property name="passwordRecover"><value>pwd-recovery</value></property>
<property name="finish"><value>finish</value></property>
<property name="nflow"><value></value></property>
</bean>

我的流程处理程序:

package com.mycompany.login.portlet;

import javax.servlet.http.HttpServletRequest;

import org.springframework.webflow.core.collection.LocalAttributeMap;
import org.springframework.webflow.core.collection.MutableAttributeMap;
import org.springframework.webflow.mvc.portlet.AbstractFlowHandler;


public class ViewFlowHandler extends AbstractFlowHandler{
public String getFlowId() {
return "main-flow";
}

}

入口点是主流,它基于名为“flo”的 url 中的 get 参数将重定向到子流。目前,当我尝试直接访问它时,我的 requestParameter 映射是空白的。我不知道在这种情况下 url 是什么。当前 URL 的示例是“http://localhost:8080/portal/portal/default/Login/Mycompany+LoginWindow?flo=pwd-recovery”。稍后我还想在 URL 中传递其他参数,例如 userid 等,但我现在得到的是 requestParameters 的空白映射。这是我的入口点流程定义

主流程.xml

http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

<action-state id="branch">
<on-entry>
<!-- <evaluate expression="flowNames.setNflow(requestParameters.flo)"/> -->
<evaluate expression="flowNames.checking(requestParameters)"/>
</on-entry>

<evaluate expression="flowNames.enableTransition()" />
<transition on="yes" to="proceed" />

</action-state>


<action-state id="proceed">

<!--<if test="flowNames.nflow==''" then="login"/>
<if test="flowNames.nflow=='pwd-recovery'" then="pwd-recovery"/>
<if test="flowNames.nflow=='finish'" then="finish-main"/>-->

<on-entry>
<!-- <evaluate expression="flowNames.setNflow(requestParameters.flo)"/> -->
<evaluate expression="flowNames.checking(requestParameters)"/>
</on-entry>

<evaluate expression="flowNames.nflow"/>
<transition on="pwd-recovery" to="pwd-recovery"/>
<transition on="finish" to="finish-main"/>
<transition to="login"/>

</action-state>

<subflow-state id="login" subflow="login-flow">
<transition on="finish-login" to="proceed"/>
</subflow-state>

<subflow-state id="pwd-recovery" subflow="pwd-recovery-flow">
<transition on="finish-pwd" to="proceed"/>
</subflow-state>

<end-state id="finish-main"/>

最佳答案

我认为您的问题不在于 Spring Webflow,而在于 portlet。查看:

http://wpcertification.blogspot.com/2010/05/getting-query-string-of-portal-url-from.html

其中显示了一种从 portlet 获取请求参数的方法。但是我不知道如何从 Spring webflow 中执行此操作 - 尽管我正在尝试找出答案!!!

关于url - spring webflow + portal - 如何获取流定义中的url参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4572495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com