spring-mvc

Spring + Hibernate: I can't delete a record from a table

爷,独闯天下 提交于 2020-01-11 09:27:04
问题 I am quite new in Spring field and in this time I am studying how integrate it with Hibernate to create my DAO object but I am finding some difficulties with the DELETE operation... So I have a person table and I have create this concrete class that implement my DAO object: package org.andrea.myexample.HibernateOnSpring.dao; import java.util.List; import org.andrea.myexample.HibernateOnSpring.entity.Person; import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate

How to maintain, update application properties dynamically in Spring? [duplicate]

﹥>﹥吖頭↗ 提交于 2020-01-11 08:38:08
问题 This question already has answers here : How can I reload properties file in Spring 4 using annotations? (3 answers) Closed 3 years ago . I would like to maintain a list of application properties like service endpoints, application variables, etc. in a Spring application. These properties should be able to updated dynamically (possibly through an web page by system administrator). Does spring has an inbuilt feature to accomplish this requirement? 回答1: I am not sure spring has an

No mapping found for HTTP request with URI [/myappname/] in DispatcherServlet with name 'appServlet'

谁都会走 提交于 2020-01-11 07:17:51
问题 I have got error No mapping found for HTTP request with URI [/myappname/] in DispatcherServlet with name 'appServlet' when I was starting my project on JBoss. This is issue has occurred after resolving another issue described here: "No Session found for current thread" after changing access method to the session Before everything was working fine. I am using Apache Tiles 2. I am reading few similar questions but I can't find working solution. This is my DispatcherServlet Context file without

Spring FileSystemXmlApplicationContext don't find the bean configuration file and go into error

折月煮酒 提交于 2020-01-11 07:16:28
问题 I am trying to do the following Spring "Hello World" example that use the FileSystemXmlApplicationContext as implementation of ApplicationContext interface. This implementation have to take the full path of the XML bean configuration as constructor parameter, something like the previous example: ApplicationContext context = new FileSystemXmlApplicationContext("C:/Users/ZARA/workspace/HelloSpring/src/Beans.xml"); I use Linux and my Beans configuration file is under the following path: /home

Set spring security remember me cookie after login via facebook

无人久伴 提交于 2020-01-11 07:08:28
问题 I am building a mobile web app that has the option to login via facebook/twitter. I want the app to remember the login via Spring security's remember me functionality so that the user need to have to login frequently. I have the parts that will call out to facebook and get the access_token that will identify the user. I can login the user using SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken(principal, credentials, authorities)); I am trying to

SAML Http Request Intercept with Spring Boot

若如初见. 提交于 2020-01-11 04:59:27
问题 In reference to this SO question Add request parameter to SAML request using Spring Security SAML I am wanting to replace the default HTTPRedirectDeflateBinding bean with my own that has a custom HTTPRedirectDeflateEncoder to add query params to my SAML request. I'm trying to achieve this with the Spring Boot @Bean auto-configuration annotation and being new to the Java environment I can't seem to get it working right. I can see that my bean is registering on startup but the outbound HTTP

Should validators in spring access the database?

怎甘沉沦 提交于 2020-01-11 04:49:06
问题 I'm not really sure if it's a good design decision to make the validators validate commands based on the state of the database. For example if I need to validate a User bean besides checking if the email and username are empty etc. I also need to reject values if they are already used. Should this kind of logic go in the validators or the service objects? 回答1: Well your validators are just spring beans, right, so they can be injected with the service objects that handle data access. You can

spring-mvc: how to map URI templates in the form of “a/b/{c}”?

ぐ巨炮叔叔 提交于 2020-01-11 04:01:10
问题 I can get a URI template in the form of "/a/b" or "/a/{b}" to work. But when I try "/a/b/{c}", I get a HTTP 404 and a message in the log in the form of "No mapping found for HTTP request with URI [/myapp/a/b/c]..." But I see these message in the log also which leads me to believe that the mappings are correct...? INFO: Mapped URL path [/a] onto handler 'AController' Nov 16, 2010 12:18:39 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path

How to call a method for every page?

戏子无情 提交于 2020-01-11 03:09:07
问题 I'm writing an application using Spring MVC. I have a method that returns values from a database. And I want to display these values in the site's header (which is shown on all pages). How I can do this? I need to call this method in every controller. 回答1: Declare a class with @ControllerAdvice annotation, then declare a method with @ModelAttribute annotation. For example: @ControllerAdvice public class GlobalControllerAdvice { @ModelAttribute public void myMethod(Model model) { Object

Spring MVC: @SessionAttributes shared among controllers?

你说的曾经没有我的故事 提交于 2020-01-11 03:01:08
问题 I have an abstract controller support class for searches and result lists: @Controller @SessionAttributes("query") public abstract class SearchController<Q extends SearchQuery> { @RequestMapping public String performSearch(@ModelAttribute("query") Q query) { .... } @ModelAttribute("query") public abstract Q createDefaultSearchQuery(); } Several actual search controllers extend this base class. After having accessed one of the controllers (say /searchBooks.html using BookSearchQuery implements