spring-mvc

@Autowired field get null

孤人 提交于 2020-02-01 08:36:27
问题 I have this property-editor for my class Categoria and im trying to auto-wired it to the service, the problem its that the services keep getting a null value. Also it seems like this is isolated or at least thats what i think, because i auto-wired a field of the same class at a controller, so i don't know whats going on, i already got an error like this, but at that time it didn't work at all . Convertor package com.carloscortina.paidosSimple.converter; import java.beans.PropertyEditorSupport

javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property

馋奶兔 提交于 2020-02-01 07:04:51
问题 I am creating Sample Spring MVC application. In my Controller class I have define like this: Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("now", now); myModel.put("products", this.productManager.getProducts()); return new ModelAndView("hello", "model", myModel); When I put following part in my JSP file i got javax.el.PropertyNotFoundException exception <c:forEach items="${model.products}" var="prod"> <c:out value="${prod.description}"/> <i>$<c:out value="${prod

javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property

懵懂的女人 提交于 2020-02-01 07:03:21
问题 I am creating Sample Spring MVC application. In my Controller class I have define like this: Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("now", now); myModel.put("products", this.productManager.getProducts()); return new ModelAndView("hello", "model", myModel); When I put following part in my JSP file i got javax.el.PropertyNotFoundException exception <c:forEach items="${model.products}" var="prod"> <c:out value="${prod.description}"/> <i>$<c:out value="${prod

javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property

我怕爱的太早我们不能终老 提交于 2020-02-01 07:03:16
问题 I am creating Sample Spring MVC application. In my Controller class I have define like this: Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("now", now); myModel.put("products", this.productManager.getProducts()); return new ModelAndView("hello", "model", myModel); When I put following part in my JSP file i got javax.el.PropertyNotFoundException exception <c:forEach items="${model.products}" var="prod"> <c:out value="${prod.description}"/> <i>$<c:out value="${prod

java.lang.ClassCastException: String can't be cast to Date

心不动则不痛 提交于 2020-02-01 06:56:25
问题 Stacktrace: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date at org.hibernate.type.descriptor.java.JdbcTimestampTypeDescriptor.unwrap(JdbcTimestampTypeDescriptor.java:41) at org.hibernate.type.descriptor.sql.TimestampTypeDescriptor$1.doBind(TimestampTypeDescriptor.java:65) at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:90) at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:286) at org.hibernate.type

Handling MaxUploadSizeExceededException with Spring MVC

给你一囗甜甜゛ 提交于 2020-02-01 05:28:05
问题 How can I intercept and send custom error messages with file upload when file size is exceeded. I have an annotated exception handler in the controller class, but the request does not come to the controller. The answer I came across on this link How to handle MaxUploadSizeExceededException suggests implementing HandlerExceptionResolver. Have things changed in Spring 3.5 or is that still the only solution? 回答1: I ended up implementing HandlerExceptionResolver: @Component public class

Order of @ExceptionHandler

*爱你&永不变心* 提交于 2020-02-01 02:04:33
问题 I use @ControllerAdvice to handle all my app exceptions : @ControllerAdvice public class ExceptionHandlingController { @ExceptionHandler({UnauthorizedException.class}) public String unauthorizedException() { ......... } @ExceptionHandler({UnauthorizedAjaxException.class}) @ResponseBody public void unauthorizedAjaxException() { ......... } @ExceptionHandler({Exception.class}) public String globalException(){ ......... } } And somewhere in my code i do throw new UnauthorizedException(); @Around

Order of @ExceptionHandler

别来无恙 提交于 2020-02-01 02:04:25
问题 I use @ControllerAdvice to handle all my app exceptions : @ControllerAdvice public class ExceptionHandlingController { @ExceptionHandler({UnauthorizedException.class}) public String unauthorizedException() { ......... } @ExceptionHandler({UnauthorizedAjaxException.class}) @ResponseBody public void unauthorizedAjaxException() { ......... } @ExceptionHandler({Exception.class}) public String globalException(){ ......... } } And somewhere in my code i do throw new UnauthorizedException(); @Around

Writing Maven Dependency for javax.persistence

别来无恙 提交于 2020-01-31 22:40:28
问题 Can someone help me write the dependency for javax.persistence . I have googled it but nothing worked. I bumped into this page that gives some details on how to write the dependency, but yet i am unable to write it. Can someone help me out? 回答1: This is the one for javax.persistence : <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0.2</version> <scope>provided</scope> </dependency> and this is for the whole Java EE 6 stack: <dependency>

How to skip jackson timezone correction in spring-mvc?

僤鯓⒐⒋嵵緔 提交于 2020-01-31 18:10:42
问题 I want to configure jackson to output any date/time values with the following format: spring.jackson.date-format=yyyy-MM-dd'T'HH:mm:ss I'm fetching many database rows and return them just as a json map. @RestController public class MyService { @GetMapping public List<Map<String, Object>> get(Param params) { return jdbcTemplate.queryForList(sql, params); } } Problem: the databases and jvm default timezone is Europe/Berlin , thus UTC+2. Therefor jackson automatically converts any database