小编Jap*_*edi的帖子

如何验证动态生成的字段服务器端

我使用Spring 3.1开发了一个Web应用程序

在其中一个模块中,我需要保存一个具有许多OperationParameter对象的Operation对象.因此,在视图中,我为用户提供了添加按钮,以便为特定操作创建OperationParameters.

两个模型都有hibernate映射,Operation和OperationParameter之间有一对多的关系.在操作模型中,我将具有操作参数列表,当用户动态添加操作参数创建新操作时,将在数据库中插入操作参数列表.

当我不使用验证时,它工作正常.当我为Operation model插入操作时,OperationParameters列表也将插入OperationParameter表中.

我的问题是如何为OperationParameter字段进行服务器端验证?如果验证是错误的,那么我如何显示特定OperationParameter字段的错误?

Operation.java

    package com.abcprocure.servicerepo.model;
// Generated Feb 9, 2012 11:30:06 AM by Hibernate Tools 3.2.1.GA


import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.collections.FactoryUtils;
import org.apache.commons.collections.list.LazyList;

@Entity
@Table(name="Operations"
    ,schema="dbo"

)
public class Operations  implements java.io.Serializable {


     private int operationId;
     @Embedded
     private Services services;
     private String operationName;
     private String isHqlsql;
     private String isMultipleTables;
     private String listOfTablesAffected; …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc hibernate-validator spring-3

4
推荐指数
1
解决办法
3764
查看次数

在群集环境中部署应用程序时,FlashAttributes无法正常工作

我正在使用redirectAttributes将成功或失败消息传递给重定向的URL.这样我只能在重定向页面上显示成功或失败消息一次.如果再次刷新同一页面,则该消息将不会再次出现.这是正常的,并且在tomcat上正常部署时工作正常.

现在我们已经设置了一个集群环境,我们已经部署了Web应用程序.但在这种情况下,redirectAttributes工作得很奇怪.有时它有效,有时不行.

以下是我用于将flashAttribute添加到重定向属性的代码行.

redirectAttributes.addFlashAttribute("successMsg", message);
Run Code Online (Sandbox Code Playgroud)

我使用Spring 3.1.0.RELEASE版本和Tomcat 7用于集群环境.

我想知道这个问题是否有任何解决方法.是否有更新的Spring版本支持在集群环境中使用redirectAttributes?如果还有其他方法可以执行此类操作,您也可以告诉我.

提前致谢.

spring spring-3

3
推荐指数
1
解决办法
1454
查看次数

在Spring Framework中将@Value注释与静态最终变量一起使用

我想使Spring应用程序中的请求映射动态化。这样我的网址就无法理解了。而且我可以向用户显示任何无意义的内容,并且仍然可以解决映射的目的。

为此,我将URL的动态部分存储在属性文件中。并希望在@RequestMapping注释中使用它。同样的事情将在JSP的客户端上完成。我将从属性文件中读取值,然后创建href。

我正在使用@Value注释读取属性文件的值。

有一个类将所有此类值保存在最终的静态变量中。

public class UrlMappingAbstraction {
    public static final @Value("#{urlAbstractionProperties['url.message']?:'message'}") String MESSAGE = "";
}
Run Code Online (Sandbox Code Playgroud)

我在控制器中扩展此类,并在@RequestMapping注释中使用static final字段,如下所示。

@RequestMapping(value="/"+MESSAGE+"/{id}", method=RequestMethod.GET)
Run Code Online (Sandbox Code Playgroud)

而且在jsp中,我还使用<spring:message/>并在href中生成url 来从属性文件中读取值。

问题是jsp能够基于属性文件值创建正确的url,但是在@RequestMapping批注中我的值没有被替换。

有人可以告诉我确切的问题吗?我知道初始化后我们无法更改静态最终变量的值。那么@Value注释的用途是什么。

如果可以通过其他方法完成,那么您也可以向我展示。

提前致谢。

spring spring-mvc spring-el spring-3

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

在jsp下具有多个子文件夹的内部资源视图解析器

嗨我使用内部资源视图解析器和我的jsp结构就像jsp/adm,jsp/icon,jsp/iload,喜欢
和我的基于注释的控制器将根据条件返回字符串值我的问题是jsp uder子文件夹没有被重新分区但它是在jsp文件夹下工作可以任何人请帮助我在这他是我的代码:`

 <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/jsp/"/>
  <property name="suffix" value=".jsp"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

我的控制器代码是

@RequestMapping("/icrl")
    public String search() throws Exception
    {
        setMenuName(CommonConstants.ICRL);
        return "pgiCRL";
    }

    @RequestMapping("/searchCodes")
    public String searchCodes() throws Exception
    {
        String key=getSearchKey();  
        String query=getQuery();
        Map<String, Object> searchKeys = new HashMap<String, Object>();
        ArrayList<String> list=new ArrayList<String>();
        if(query!=null||!query.isEmpty()){
            searchKeys.put(CommonConstants.DIAGICD9, getDiaICD9());
            searchKeys.put(CommonConstants.DIAGICD10, getDiaICD10());
            searchKeys.put(CommonConstants.DIAGNOSIS, getDiagnosis());
            searchKeys.put(CommonConstants.PROCEDURE, getProcedure());
            searchKeys.put(CommonConstants.SURGICAL, getSurgical());
            searchKeys.put(CommonConstants.SURGICAL9, getSurICD9());
            searchKeys.put(CommonConstants.SURGICAL10, getSurICD10());
            searchKeys.put(CommonConstants.REVENUE, getRevenue());
            list= (ArrayList<String>) iCRLService.getSearchCodeList(query,searchKeys);  
        }
        setSuggestions(list);
        return CommonConstants.SUCCESS;
    }
Run Code Online (Sandbox Code Playgroud)

我的视图取决于条件它可能是成功页面和失败页面所以我需要修复控制器中的返回值,因为这是动态的.提前致谢

spring-mvc

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