小编Pau*_*ick的帖子

Struts 2操作类型使用注释转换列表

我正在尝试创建一个自定义类型转换器来转换来自String的对象集合.我的表单中有一个文本区域,并希望在我保存的文本区域中的每个换行符的Collection中创建一个新对象.在显示信息时,我想循环遍历Collection中的对象并将其转换为带有文本区域换行符的String.到目前为止,根据我的注释,我甚至无法启动转换器或接收任何类型的错误.以下是我的班级定义:

@Conversion()
public class FormsEdit extends JWebCrud{
Run Code Online (Sandbox Code Playgroud)

在这个课程里面我有一个List:

private List<Formfield> formFields;
Run Code Online (Sandbox Code Playgroud)

在Formnfield类里面我有一个Set:

private Set<Formfieldopts> formfieldoptses = new HashSet<Formfieldopts>(0);

@TypeConversion(converter = "com.webexchange.actions.tpa.setup.forms.FormFieldOptsConverter")
public void setFormfieldoptses(Set<Formfieldopts> formfieldoptses) {
    this.formfieldoptses = formfieldoptses;
}
Run Code Online (Sandbox Code Playgroud)

有人可以指导我如何正确设置这些注释以使转换器启动?

Struts 2版本: 2.2.1

Struts拦截器堆栈:

            <interceptor-stack name="stackWithSecurity">
                            <interceptor-ref name="closeHibernateSession" />
            <!--catches exceptions pre or post action class-->
            <interceptor-ref name="exceptionInterceptor" />  
            <interceptor-ref name="security">
                <param name="excludeMethods">executeNoSecurity,executeNoSecurityOrValidation</param>
            </interceptor-ref>
            <interceptor-ref name="alias" />
            <interceptor-ref name="servletConfig" />
            <!-- Puts HTTPResponse and HTTPRequest objects on the action -->
             <interceptor-ref name="openHibernateSession" />
            <!-- Opens a db connection and …
Run Code Online (Sandbox Code Playgroud)

java struts2

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

标签 统计

java ×1

struts2 ×1