spring-mvc

Are Spring MVC Controllers Singletons?

末鹿安然 提交于 2020-01-09 03:02:45
问题 I have a query regarding Spring 3 MVC @Controllers . When a request comes in, does the container create a new instance of the controller for each request (Similar to an Action in Struts 2 - ThreadLocal ActionContext ) or a single instance responds to all requests? By default are the controller beans singletons in a context? What are the guidelines/ best practices for a Spring 3 MVC application? Are these settings configurable? Should those be configured? Does it change much if my environment

Are Spring MVC Controllers Singletons?

≡放荡痞女 提交于 2020-01-09 03:02:35
问题 I have a query regarding Spring 3 MVC @Controllers . When a request comes in, does the container create a new instance of the controller for each request (Similar to an Action in Struts 2 - ThreadLocal ActionContext ) or a single instance responds to all requests? By default are the controller beans singletons in a context? What are the guidelines/ best practices for a Spring 3 MVC application? Are these settings configurable? Should those be configured? Does it change much if my environment

Spring - Redirect after POST (even with validation errors)

五迷三道 提交于 2020-01-08 13:53:14
问题 I'm trying to figure out how to "preserve" the BindingResult so it can be used in a subsequent GET via the Spring <form:errors> tag. The reason I want to do this is because of Google App Engine's SSL limitations. I have a form which is displayed via HTTP and the post is to an HTTPS URL. If I only forward rather than redirect then the user would see the https://whatever.appspot.com/my/form URL. I'm trying to avoid this. Any ideas how to approach this? Below is what I'd like to do, but I only

Setting Precedence of Multiple @ControllerAdvice @ExceptionHandlers

半腔热情 提交于 2020-01-08 11:36:08
问题 I have multipler classes annotated with @ControllerAdvice , each with an @ExceptionHandler method in. One handles Exception with the intention that if no more specific handler is found, this should be used. Sadly Spring MVC appears to be always using the most generic case ( Exception ) rather than more specific ones ( IOException for example). Is this how one would expect Spring MVC to behave? I'm trying to emulate a pattern from Jersey, which assesses each ExceptionMapper (equivalent

Setting Precedence of Multiple @ControllerAdvice @ExceptionHandlers

一曲冷凌霜 提交于 2020-01-08 11:35:15
问题 I have multipler classes annotated with @ControllerAdvice , each with an @ExceptionHandler method in. One handles Exception with the intention that if no more specific handler is found, this should be used. Sadly Spring MVC appears to be always using the most generic case ( Exception ) rather than more specific ones ( IOException for example). Is this how one would expect Spring MVC to behave? I'm trying to emulate a pattern from Jersey, which assesses each ExceptionMapper (equivalent

How to reset values on each page view

时间秒杀一切 提交于 2020-01-08 03:58:39
问题 I have a basic app in SpringMVC. All of my controllers extend a super class shown below. The problem here is that the cssFiles and jsFiles are not reset every time a controller method is touched. So I end up with content/view.js being loaded x+1 times for every page view. If I've loaded the page 3 times, it'll contain 4x content/view.js files. I'm seeing these values be appended to each time the page is loaded. Why is this happening and how do I fix it? public class Controller { private List

How to reset values on each page view

主宰稳场 提交于 2020-01-08 03:58:07
问题 I have a basic app in SpringMVC. All of my controllers extend a super class shown below. The problem here is that the cssFiles and jsFiles are not reset every time a controller method is touched. So I end up with content/view.js being loaded x+1 times for every page view. If I've loaded the page 3 times, it'll contain 4x content/view.js files. I'm seeing these values be appended to each time the page is loaded. Why is this happening and how do I fix it? public class Controller { private List

spring error :org.springframework.web.context.ContextLoader - Context initialization failed

旧时模样 提交于 2020-01-07 09:02:36
问题 I am developing a simple project in spring but I have the following problem org.springframework.web.context.ContextLoader - Context initialization failed this is the controller: package com.linedata.jaba.controllers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.linedata.jaba.metier.IBanqueMetier; @Controller public class BanqueController { @Autowired

Accessing a variable outside java code fragment in a jsp(Spring MVC)

耗尽温柔 提交于 2020-01-07 09:02:23
问题 in my scenario i have a code like below: <c:forEach items="${dbEntries}" var="c" varStatus="loop"> <tr> <% int i = 0; System.out.println(i); %> <td rowspan="1">${c.getRh_name()}</td> <td rowspan="1">${c.getIpm_name()}</td>` </tr> </c:forEach> now i want to access the variable from html. like below <h1>${i}</h1> but its not displaying.can anyone help?? 回答1: Use jstl instead of java code inside jsp like this. <c:set var="salary" scope="session" value="${2000*2}" /> <c:out value="${salary}" />

Spring root WebApplicationContext not getting initialized in eclipse

泪湿孤枕 提交于 2020-01-07 06:52:28
问题 I downloaded a project from http://www.journaldev.com/3531/spring-mvc-hibernate-mysql-integration-crud-example-tutorial I configured it according to my db env, Problem I am facing is, when I start the server(tomcat) in eclipse. It gets started but application doesn't get started. I found that it is not giving logs of initializing of splrig root webapplication context. Logs generated on start up are Jan 13, 2015 10:34:52 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based