标签: spring-webflow-2

单元测试嵌套子流(子流的子流)

我正在尝试为具有子流的流编写单元测试,该子流本身具有另一个子流.

我使用注册第一流程 FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory).

然后我FlowDefinitionRegistry在转换到它们之前在测试执行期间注册子流定义.

转换到"第一级"子流程就可以了.转换到当前子流的子流的结果 - NoSuchFlowDefinitionException.

问题是子流定义似乎都附加到测试的主要流程,并且在另一个子流程中找不到子流程.

有没有办法将子流定义附加到测试中的另一个子流,哪些扩展AbstractXmlFlowExecutionTests

java junit unit-testing spring-webflow spring-webflow-2

7
推荐指数
1
解决办法
1395
查看次数

Spring Webflow可以消除对控制器类的需求吗?

对于一个相对简单的应用程序,可以使用Webflow来减少创建表单控制器的需要吗?嗯,当然可以,但我想我要问的是:如果我这样做的目的是减少我写的代码量,我可以而且应该使用Webflow为所有控制器/视图逻辑编写整个应用程序?

我正在努力通过(糟糕的)Webflow文档,我想知道它是否值得,或者我是否应该坚持常规的MVC.

spring spring-mvc spring-webflow-2

6
推荐指数
1
解决办法
1914
查看次数

如何在Spring WebFlow中处理CommonsMultipartResolver中的SizeLimitExceededException?

我有以下情况.我有一个CommonsMultipartResolver bean以下面的方式配置.

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="2100000" />
Run Code Online (Sandbox Code Playgroud)

我在Spring Web Flow视图状态jsp中有一些文件上载字段.

如果文件低于限制,一切正常,但如果文件超过2MB-s的限制,我必须在表单上的绑定结果中添加验证错误.

我的问题是多部分文件解析器在超出文件限制时抛出org.apache.commons.fileupload.FileUploadBase.SizeL imitExceededException异常,我找不到在Spring Web Flow中捕获它的方法并将我的FieldError添加到形成.

我尝试使用transition标记的on-exception属性,但如果我理解正确,它只适用于Spring Web Flow中抛出的异常.

我也尝试在spring mvc中使用SimpleMappingExceptionResolver,但我不想重定向到页面,我想处理这个异常.

我也发现了这个:https://jira.springsource.org/browse/SWF-158

但是它来自版本1.0,我假设这已经被合并,或者找到了一种更好的方法来处理这些情况.

任何关于如何处理这个问题的想法将不胜感激.

谢谢.

spring-webflow spring-webflow-2 apache-commons-fileupload

6
推荐指数
1
解决办法
4407
查看次数

如何在Spring Security 3中设置用户角色?

我正在研究JAVA EE技术以学习JSF-Spring-Hibernate vs ...我正在尝试使用不同的用户角色来执行Web应用程序.现在,我只有一个用户角色ROLE_USER.我无法改变这个角色.我尝试使用debug mod来理解我们如何设置这个角色,但我无法理解它在哪里发生.

所以,我的主要问题是我无法在我的应用程序中创建任何其他ROLE.如果我不使用<secured attributes="ROLE_USER" />我的流程(我使用spring web-flow),每个人都可以访问该页面.如果我只做ROLE_USER.但我想创建一个名为ROLE_ADMIN的新角色,只让ROLE_ADMIN到达该页面.

注意:我没有在这里添加所有文件因为我说只添加相关的类和文件.如果您需要更多信息,请告诉我.

这是我正在遵循的教程soruce代码. https://code.google.com/p/jee-tutorial-youtube/source/browse/

安全-config.xml中

<?xml version="1.0" encoding="UTF-8"?>
Run Code Online (Sandbox Code Playgroud)

<security:http auto-config="true">
    <security:form-login login-page="/app/main"
        default-target-url="/app/account" />
    <security:logout logout-url="/app/logout"
        logout-success-url="/app/main" />
</security:http>

<security:authentication-manager>
    <security:authentication-provider
        user-service-ref="userServiceImp">
        <security:password-encoder hash="md5" />
    </security:authentication-provider>
</security:authentication-manager>

<bean id="daoAuthenticationProvider"
    class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
    <property name="userDetailsService" ref="userServiceImp" />
    <property name="hideUserNotFoundExceptions" value="false" />
</bean>

<bean id="authenticationManager"
    class="org.springframework.security.authentication.ProviderManager">
    <constructor-arg>
        <ref bean="daoAuthenticationProvider" />
    </constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)

这是我的UserAuthenticationProviderServiceImp类,我在其中验证用户身份.

 public boolean processUserAuthentication(Users user) {

        try {
                Authentication request = new UsernamePasswordAuthenticationToken(user.getUserName(), user.getPassword());
                Authentication result = authenticationManager.authenticate(request);
                SecurityContextHolder.getContext().setAuthentication(result);

                return true;
        } …
Run Code Online (Sandbox Code Playgroud)

authentication spring roles spring-security spring-webflow-2

6
推荐指数
1
解决办法
1万
查看次数

无法找到元素'flow'的Spring NamespaceHandler

我正在使用SpringSource Tool Suite开发一个spring webflow(2.0.7)项目.我正在尝试设置基本流程.

我的someflow.xml看起来像这样:

    <flow xmlns="http://www.springframework.org/schema/webflow"  
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.springframework.org/schema/webflow
                              http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

             <!- view-state declarations -->
    </flow>
Run Code Online (Sandbox Code Playgroud)

在STS工具(eclipse上的Spring IDE)中,我在流schemaLocation附近看到一条警告消息:

无法为模式名称空间'http:// www.springframework.org/schema/webflow'的元素'flow'找到Spring NamespaceHandler

然后当tomcat启动时,我收到错误

org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:无法找到XML架构命名空间的Spring NamespaceHandler [ http://www.springframework.org/schema/webflow] 攻击资源:ServletContext资源[/ WEB-INF /流/ someflow.xml]

  • 我google了一段时间,一些帖子表明问题是spring-webflow jar不在类路径中.在我的例子中,springsource工具创建了模板,所有的jar都到位了.我也手动检查了它们.所以这不是问题

  • 这篇文章http://forum.springsource.org/archive/index.php/t-49098.html中的一条建议是拼接罐子!这不是一个解决方案,但我试图看看它是否修复了它.但不是.

现在被困......其他人是否面临这个问题?

spring spring-webflow spring-webflow-2

5
推荐指数
1
解决办法
1338
查看次数

5
推荐指数
1
解决办法
7418
查看次数

Spring Webflow绑定:Converter - java.lang.IllegalArgumentException:每个转换器对象必须实现一个Converter ...接口

我在Spring的XML配置文件之一中有以下代码:

  <mvc:annotation-driven conversion-service="conversionService" />

  <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
    <property name="converters">
        <list>
            <bean class="org.springframework.binding.convert.converters.StringToDate">
                <property name="pattern" value="yyyy-MM-dd" />            
            </bean>
        </list>
    </property>
  </bean>
Run Code Online (Sandbox Code Playgroud)

但是我在部署期间遇到了以下异常(在JBoss上):

java.lang.IllegalArgumentException:每个转换器对象必须实现Converter,ConverterFactory或GenericConverter接口之一

知道为什么吗?据我所见,org.springframework.binding.convert.converters.StringToDate是一个实现Converter.

更新:

刚刚找到这个答案,这表明混合Converters和PropertyEditors可能会导致问题.我确实参与了我的应用程序使用PropertyEditors,但据我所知,文档没有讨论混合两个系统的任何问题.

堆栈跟踪:

Caused by: java.lang.IllegalArgumentException: Each converter object must implement one of the Converter, ConverterFactory, or GenericConverter interfaces
    at org.springframework.core.convert.support.ConversionServiceFactory.registerConverters(ConversionServiceFactory.java:106)
    at org.springframework.context.support.ConversionServiceFactoryBean.afterPropertiesSet(ConversionServiceFactoryBean.java:56)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 146 more
Run Code Online (Sandbox Code Playgroud)

更新2:

我改变了我的xml:

  <mvc:annotation-driven conversion-service="conversionService" />

  <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
    <property name="converters">
        <set>
            <bean …
Run Code Online (Sandbox Code Playgroud)

java spring exception spring-webflow spring-webflow-2

5
推荐指数
1
解决办法
3929
查看次数

EL中的Spring webflow完整查询字符串

简而言之,如何在webflow视图jsp中使用EL获取完整的查询字符串?这就是我想要做的:

<span class="forgot-password">
  <a href="forgotPasswordRequest?<%=request.getQueryString() %>">
    <spring:message code="screen.welcome.link.forgotPassword" />
  </a>
</span>
Run Code Online (Sandbox Code Playgroud)

除了我想使用EL而不是scriptlet <%=request.getQueryString() %>.使用任何单个参数似乎很容易${param.someParameterName},但我想要整个事情.更具体地说,我使用CAS作为SSO提供商.为了进行身份验证,应用程序会使用包含参数的查询字符串将其登录名重定向到CAS,该参数service是成功进行身份验证后要返回的URL.像这样的东西:

?service=http%3A%2F%2Fmysite.com%3A9080%2Fwelcome
Run Code Online (Sandbox Code Playgroud)

我的CAS登录页面有一个忘记密码webflow的链接.我需要将该服务参数传播到其他Web流.所以我可以这样做:

<span class="forgot-password">
  <a href="forgotPasswordRequest?service=${param.service}">
    <spring:message code="screen.welcome.link.forgotPassword" />
  </a>
</span>
Run Code Online (Sandbox Code Playgroud)

但后来我失去了所有的网址转义.此外,如果将来还有其他要保留的参数,它们也会丢失.

这个小脚本目前有效,但它很难看,我不喜欢在我的演示文稿中使用代码(因为这是真正的java代码),尽管它很简单.EL肯定是一个更优雅的解决方案.

我探讨了spring文档中列出的所有特殊EL变量,但仍无法找到获取完整queryString的方法.

-------------------------------- UPDATE ----------------- ---------------

好吧,所以我正在制定一些理由......结果是ExternalContext界面有一个getNativeRequest()实际的HttpServletRequest对象.从那里我可以得到完整的查询字符串:

externalContext.getNativeRequest().getQueryString()
Run Code Online (Sandbox Code Playgroud)

所以现在我假设因为有一个名为externalContext 的特殊EL变量,我会这样做:

${externalContext.nativeRequest.queryString}
Run Code Online (Sandbox Code Playgroud)

对?错误!事实证明externalContext,JSP页面中没有该变量.谁知道为什么?但是,还有flowRequestScope,JSP可用并且有一个getExternalContext方法,所以现在我可以这样做:

${flowRequestScope.externalContext.nativeRequest.queryString}
Run Code Online (Sandbox Code Playgroud)

很酷,有效......但为什么有必要呢?为什么只有一些特殊的EL变量被推送到JSP页面,为什么它们中的一些变化(viewScope似乎它的所有值都被提升到root级别,因此viewScope.commandName在JSP中被引用为$ {commandName} EL)?我必须错过WebFlow工作方式的基本内容.有人能指出我正确的方向吗?

java spring spring-mvc spring-webflow-2

5
推荐指数
1
解决办法
1662
查看次数

如何在Spring中处理MultipartException

我的配置在这里

我根据帖子中的答案进行了一些修改。

filterMultipartResolver

@Bean
public StandardServletMultipartResolver filterMultipartResolver() {
    return new StandardServletMultipartResolver();
}
Run Code Online (Sandbox Code Playgroud)

AppInitializer

public class AppInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(final ServletContext servletContext) throws ServletException {
        // Create the 'root' Spring application context
        final WebApplicationContext context = getContext();
        // Manage the lifecycle of the root application context
        servletContext.addListener(new ContextLoaderListener(context));
        final Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context));
        dispatcher.setMultipartConfig(getMultipartConfigElement());
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");
    }

    private static AnnotationConfigWebApplicationContext getContext() {
        final AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.register(AppConfig.class);
        return context;
    }

    private …
Run Code Online (Sandbox Code Playgroud)

java tomcat spring-security spring-webflow-2

5
推荐指数
1
解决办法
2970
查看次数

Spring WebFlow的未来和版本

这更适合Spring Team支持Spring WebFlow -

什么是Spring WebFlow路线图.你能描述它的版本约定它是如何与其他核心Spring产品不同的.

Spring WebFlow 2.4中提供的Ex Spring 4支持不是3.为什么它保留在2.X版并且没有移到3?

另外我听说有传言说Spring WebFlow不会被支持这是真的吗?

谢谢.

spring-webflow spring-webflow-2

5
推荐指数
0
解决办法
291
查看次数