Tag: spring

spring mvc date format with form:input

我有hibernate实体和bean: @Entity public class GeneralObservation { @DateTimeFormat(pattern = “dd/MM/yyyy”) Date date; @Column public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } } 我也有 @InitBinder protected void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat(“dd/MM/yyyy”); binder.registerCustomEditor(Date.class, new CustomDateEditor( dateFormat, false)); } 和 form:input id = “datepicker” name=”date” itemLabel=”date” path=”newObservation.date” […]

从Java启动Spring应用程序的exception

我能够使用Maven编译并启动我的Spring项目: mvn -e clean compile exec:java -Dexec.mainClass=de.fraunhofer.fkie.tet.vmware.manager.Test 但是,当我使用maven-assembly-plugin (包括applicationContext.xml )将所有jar组装在一个文件中时,我总是在java执行期间得到一个Exception : java -cp target/test-jar-with-dependencies.jar:. de.fraunhofer.fkie.tet.vmware.manager.Test INFO: Loading XML bean definitions from class path resource [applicationContext.xml] Sep 6, 2010 10:37:21 AM org.springframework.util.xml.SimpleSaxErrorHandler warning WARNING: Ignored XML validation warning org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document ‘http://www.springframework.org/schema/context/spring-context.xsd’, because 1) could not find the document; 2) the document […]

从Tiles视图(JSP)访问Spring bean

在Spring MVC中,我可以使用JstlView的exposedContextBeanNames(或exposeContextBeansAsAttributes)在JSP中访问我的bean。 例如,然后,在我的JSP中我可以编写($ {properties.myProperty)。 但是,当相同的JSP是切片视图的一部分时,无法访问这些属性。 是否可以正确配置Tiles或以其他方式访问这些属性? 我正在使用Spring MVC 3.0.2和Tiles 2.2.1。 这是我的一些配置: properties 编辑:我已经实施了Skaffman的解决方案。 TilesExposingBeansViewResolver.java: package es.kcsolutions.util.spring.servlet.view; import org.springframework.web.servlet.view.*; public class TilesExposingBeansViewResolver extends UrlBasedViewResolver { private Boolean exposeContextBeansAsAttributes; private String[] exposedContextBeanNames; public void setExposeContextBeansAsAttributes(boolean exposeContextBeansAsAttributes) { this.exposeContextBeansAsAttributes = exposeContextBeansAsAttributes; } public void setExposedContextBeanNames(String[] exposedContextBeanNames) { this.exposedContextBeanNames = exposedContextBeanNames; } @Override protected AbstractUrlBasedView buildView(String viewName) throws Exception […]

Spring @JsonIgnore无法正常工作

如何让@JsonIgnore工作我有一堂课。 即使我把注释放在那里它对输出也没有影响。 我在用jackson。 public class QuestionBlock implements ComparableByID{ int ID; String title; String description; boolean deleted; boolean isDraft; boolean visible; Timestamp modifiedDate; String modifiedBy; private List questions = new ArrayList(); @JsonIgnore private List surveys = new ArrayList(); … @JsonIgnore public List getSurveys() { return surveys; } @JsonIgnore public void setSurveys(List surveys) { this.surveys = surveys; […]

如何将spring beans注入jsp 2.0 SimpleTag?

目前我需要spring bean的jsp 2.0标签使用此代码: ac = WebApplicationContextUtils.getWebApplicationContext( servletContext); ac.getBeansOfType(MyRequestedClass.class); 我刚刚得到第一个匹配的bean。 这段代码工作正常,但是有一个不希望的缺点,我花了大约一半的页面渲染时间查找spring bean,因为每次调用一个标签时都会发生这种情况。 我想也许可以将bean放入应用程序范围或至少是会话范围。 但是,处理这个问题的最聪明方法是什么?

每个实体hibernate两个表

我有一个实体 – User 。 它由User.class描述。 Hibernate为每个实体创建一个表,所以当我调用session.save(user) ,我的数据总是保存到该表中。 现在我需要另一个表用于相同User类型的数据,我只需要将我的实体保存到该表。 数据结构 (类似这样): table users_1_table{ string id; string username; } table users_2_table{ string id; string username; } 使用这个 : session.save(user1,”users_1_table”) session.save(user2,”users_2_table”) 结果我应该在users_1_table有user1在users_1_table user2 。 由于系统限制,我不能将这两个对象放在一个表中。 (即使创建额外的字段也是个坏主意)。 我可以不进行子类化吗? 使用programmaticaly hibernate配置?

将ContextLoaderListener添加到Spring MVC中的web.xml

我是Spring MVC的新手。 我有一个Web应用程序。 我有以下配置: list.html spring org.springframework.web.servlet.DispatcherServlet 1 spring / 我是否需要将以下行添加到web.xml文件中? org.springframework.web.context.ContextLoaderListener

关于带注释控制器的Spring AOP建议

我试图使用AOP在带注释的控制器之后进行一些处理。 一切都在运行,没有错误,但建议没有被执行。 这是控制器代码: @Controller public class HomeController { @RequestMapping(“/home.fo”) public String home(ModelMap model) { model = new ModelMap(); return “home”; } } 和application-config中的设置 和实际的建议 public class TestAdvice implements AfterReturningAdvice { protected final Log logger = LogFactory.getLog(getClass()); public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable { logger.info(“Called after returning advice!”); } } […]

多个jpa:xml配置中的存储库,如何使用Spring java配置使用@EnableJPARepositories进行配置?

我已经研究并找到了关于如何将spring data jpa与多个数据源一起使用的解释和示例代码 ,这些数据源指的是在xml配置中配置多个jpa:repositories,如下所示: 您如何使用java配置和@EnableJpaRepositories注释声明上述两个jpa:存储库配置? 注释似乎只支持一组属性(即仅一个jpa:仅存储库),并且不可能多次声明注释。

JPA瞬态注释和JSON

这是关于JPA瞬态注释的以下问题的后续操作为什么JPA有@Transient注释? 我有一个我不想坚持的瞬态变量,它标有瞬态注释。 但是,当我想从我的其余控制器生成JSON时,此瞬态变量在输出的JSON中不可用。 POJO PublicationVO是直接的,没有花哨的属性,只有一些私有属性(持久化)与getter和setter以及1个瞬态变量。 @RequestMapping(value = { “{publicationId}”}, method = RequestMethod.GET, produces = “application/json”) @ResponseBody public PublicationVO getPublicationDetailsJSON(@PathVariable(value = “publicationId”) Integer publicationId) { LOG.info(“Entered getPublicationDetailsJSON – publicationId: ” + publicationId); //Call method to get the publicationVO based on publicationId PublicationVO publicationVO = publicationServices.getPublicationByIdForRestCalls(publicationId); LOG.info(“publicationVO:{}”, publicationVO); LOG.info(“Exiting getPublicationDetailsJSON”); return publicationVO; } PublicationVO如下 package com.trinity.domain.dao; import […]