我正在使用Grails Webflow插件.以下是我正在使用的域对象:
class Foo implements Serializable {
String fooProp1,
fooProp2
static constraints = {
fooProp2 nullable: false
}
}
class Bar implements Serializable {
Foo fooObject
static constraints = {
fooObject nullable: false
}
}
Run Code Online (Sandbox Code Playgroud)
在webflow中的某个点上,我需要确保fooObject.fooProp1不为null.如果是,我想抛出一个错误并强制用户为它提供一个值.我尝试使用validate()来执行此操作(在Bar和Foo对象上),但由于fooProp1具有nullable:true属性,因此它会通过验证.有任何想法吗?
我正在使用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中的一条建议是拼接罐子!这不是一个解决方案,但我试图看看它是否修复了它.但不是.
现在被困......其他人是否面临这个问题?
我需要调用org.hibernate.Hibernate类的静态方法.如何在流动元素中做到这一点?
当我从网页上提交角色Ö后,后端收到了Ã.该网页是Spring Webflow/JSF1.2/Facelets应用程序的一部分.当我用firebug检查POST时,我看到:
Content-Type: application/x-www-form-urlencoded
Content-Length: 74
rapport=krediet_aanvragen&fw1=0&fw2=%C3%96ZTEKIN&fw3=0&fw4=0&zoeken=Zoeken
Run Code Online (Sandbox Code Playgroud)
字符Ö编码为%C3%96,使用此表我可以看到它是UTF-8/Unicode字符Ö的正确十六进制表示.但是当它到达后端时,角色会变成Ã.使用相同的表我可以看到有些代码试图分别解释C3和96(或作为unicode\u表示法).U + 00C3恰好是Ã,96不是可见字符,因此可以解释这一点.
现在我知道这是编码不匹配的典型情况,我只是不知道在哪里修复此问题.
该网页包含
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Run Code Online (Sandbox Code Playgroud)
在调试时,我可以看到负责错误interpration的库是jboss-el 2.0.0.GA,这似乎是正确的,因为该值被解析为webflow表达式中的后端:
<evaluate expression="rapportCriteria.addParameter('fw2', flowScope.fw2)" />
Run Code Online (Sandbox Code Playgroud)
它通过以下方式放到flowScope上:
<evaluate expression="requestParameters.fw2" result="flowScope.fw2"/>
Run Code Online (Sandbox Code Playgroud)
没关系将表单输入到后端的精确方法,这是试图将Webflow与BIRT报告集成的代码......但我在其他Web应用程序中有相同的sympton.
我有什么想法开始寻找?
在我的Spring web flow应用程序中,我的一个action-state转换看起来像这样:
<transition on-exception="com.foo.BarException" to="barView">
<set name="flowScope.error" value="foo.bar" type="string" />
</transition>
Run Code Online (Sandbox Code Playgroud)
我想设置flowScope.error为文字字符串"foo.bar",但Spring将其解释为foo对象的bar属性的引用.我如何强制Spring从字面上理解字符串呢?
我在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) 我正在Spring 3.1.2 (webflow version 2.3.1)和我一起工作,我再次面临一个老问题.问题是通过Spring webflow创建一个新对象.所以我想做的是:
<set name="myBean.foo" value="new Bar()"
我做了一些研究,发现这是不行的.现在面临同样的问题,我想知道是否有一些我不了解的问题的新设施,或者是一个首选的替代方案.在过去,我使用静态工厂.
除了Alan J Liu的回答之外:每次进行某个转换时(或每次输入某个视图时)都需要启动对象.
PS:泉源在这里没有回答我的问题.提前致谢!
我应该绑定到一个复杂对象的形式,装载这种形式我必须初始化所有的孩子,只有有很多的方法,对象之前包裹了很多孩子,每次new报表和调用一个setter方法,我要对许多表单和其他复杂对象重复此方案
有没有比initializeEmployee方法更好的策略?
例如:
@Entity
public class Employee {
Integer Id;
Contract contract;
Name name;
List<Certificate> list;
// getter and setters
}
@Entity
public class Contract {
String telephoneNum;
String email;
Address address;
// getter and setters
}
@Entity
public class Address {
String streetName;
String streetNum;
String city;
}
public class Name {
String fName;
String mName;
String lName;
// getter and setters
}
// And another class for certificates
public initializeEmployee() {
Employee …Run Code Online (Sandbox Code Playgroud) 这更适合Spring Team支持Spring WebFlow -
什么是Spring WebFlow路线图.你能描述它的版本约定它是如何与其他核心Spring产品不同的.
Spring WebFlow 2.4中提供的Ex Spring 4支持不是3.为什么它保留在2.X版并且没有移到3?
另外我听说有传言说Spring WebFlow不会被支持这是真的吗?
谢谢.
我正在使用Thymeleaf Templates片段开发SpringMVC应用程序.我想添加简单的流程.这是我的项目结构和配置:
我的spring-servlet.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<!-- Deklaracja pakietów kontrolerów: -->
<context:component-scan base-package="pl.etestownik.controller"
scoped-proxy="targetClass" />
<mvc:annotation-driven
ignore-default-model-on-redirect="true" />
<mvc:default-servlet-handler />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<bean
class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer" />
</property>
</bean>
<!-- Thymeleaf konfiguracja resolverów: -->
<bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML5" />
<property name="characterEncoding" value="UTF-8" />
<property name="cacheable" value="false" />
<property name="order" value="0"></property>
</bean>
<!--
<bean id="thymeleafViewResolver" class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" …Run Code Online (Sandbox Code Playgroud) spring-webflow ×10
spring ×5
java ×4
exception ×1
facelets ×1
grails ×1
hibernate ×1
jsf ×1
spring-mvc ×1
thymeleaf ×1