spring-mvc

Capture successful login with AspectJ and Spring Security

 ̄綄美尐妖づ 提交于 2020-01-14 05:22:07
问题 i'm using spring security and AspectJ to log application's behavior. I need to capture a successful login and log it. My spring security configuration: <security:http auto-config="true" authentication-manager-ref="authenticationManager" use-expressions="true"> <security:intercept-url pattern="/login" access="permitAll"/> <security:intercept-url pattern="/loginFailed" access="permitAll"/> <security:intercept-url pattern="/viewUserAccounts" access="hasRole('ROLE_ANTANI')" /> <security:intercept

Spring Context init (java)

大城市里の小女人 提交于 2020-01-14 04:33:09
问题 I'm a beginner with spring and I am having problem with basic context init and I can't find any easy tutorial. So what I want to do is basic dependency injection and I have seen I only have to mark classes as @Componant or @Service and inject them directly within target fiels with @Autowired. For this I need to set properly my spring context (I'll need to build a web service + use JPA so I want to build a webapp) I'm using JDK 1.8, maven 3.2.1 I want to do a basic dependency injection. => I

Spring MVC: processing values from timesheet - multiple objects

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-14 04:32:58
问题 I'm working on a timesheet/actiontracker application. I'm using Spring MVC. This is my current situation: I got a form with all the tasks. Next to these tasks there are seven textboxes (which display the amount of hours for the next seven days). A user must be able to save the tasks (and the hours). I'm not really sure how to send these results to the controller. It contains a list of objects. Let's say... TaskID - Taskname - D1 - D2 - D3 ... 1 Hello 5 3 2 2 Bai 4 2 1 3 I'm back 3 4 3 It

No 'Access-Control-Allow-Origin' header is present on the requested resource in WebSockets request [duplicate]

自闭症网瘾萝莉.ら 提交于 2020-01-14 04:32:26
问题 This question already has answers here : No 'Access-Control-Allow-Origin' header is present on the requested resource—when trying to get data from a REST API (11 answers) Closed 2 years ago . I have red tons of example how to configure CORS in Java Spring, but it is still not working in project with websockets request. It works with mcv api paths, but my websockets path's returns error: Failed to load http://localhost:8080/chat/info?t=1537264329515: No 'Access-Control-Allow-Origin' header is

How to use VelocityLayoutViewResolver in spring-webmvc with velocity

南笙酒味 提交于 2020-01-14 04:12:05
问题 <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver"> <property name="prefix" value="" /> <property name="suffix" value=".vm"></property> <property name="contentType" value="text/html;charset=UTF-8" /> <property name="layoutUrl" value="layout/default.vm" /> </bean> how the key word "layoutUrl" work in VelocityLayoutViewResolver? 回答1: Its very common to have a dynamic web page divided into a layout part and a content part. The layout part

How to pass the object from one controller to another in Spring without using Session

喜欢而已 提交于 2020-01-14 04:00:30
问题 I have a requirement where the user selects some data from a form and we need to show that selected data on the next page. At present we are doing this with a session attribute, but the problem with this is that it overwrites the data if the first page is open in another browser tab, where the data is again selected and submitted. So I just want to get rid of this session attribute while transferring data from one controller to another. Note: I am using an XML based Spring configuration, so

Spring 3.1.2 MVC @ExceptionHandler with @ResponseBody

不打扰是莪最后的温柔 提交于 2020-01-14 03:43:08
问题 I'm trying to implement a Spring Web MVC @ExceptionHandler with a @ResponseBody to return an object containing validation errors. (Strategy E documented here). In Spring 3.0.x, there was a confirmed bug , since resolved, that prohibited this from working properly. I'm using Spring 3.1.2, and shouldn't be running into that one. I am, however, running into an exception"Could not find acceptable representation". Here's the exception: [10/21/12 12:56:53:296 CDT] 00000045 ExceptionHand E redacted

Error starting Tomcat context with Spring-Boot: java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSource

我们两清 提交于 2020-01-14 03:34:09
问题 I recently decide add spring-boot to a existing spring project which uses hibernate configured by java code. I have this pom.xml file: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.spring</groupId> <artifactId>app</artifactId> <version>0.1.0</version>

How to access hibernate session via AnnotationSessionFactoryBean?

不羁的心 提交于 2020-01-14 02:51:09
问题 I want to integrate hibernate with spring. spring 3 documentation says that you can access session via org.hiberate.SessionFactory's getCurrentSession() and this should be prefered over hibernateDaoSupport approach. But I want to know how can we get hold of org.hiberate.SessionFactory's instance in the first place if we are using AnnotationSessionFactoryBean? I have done the following bean declaration in applicationContext.xml: <bean id="annotationSessionFactoryBean" class="org

ResourceBundle [messages] not found for MessageSource: Can't find bundle for base name messages

旧巷老猫 提交于 2020-01-14 01:43:12
问题 In applicationContext.xml I have defined MessageSource like this: <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basenames"> <list> <value>/WEB-INF/i18n/messages</value> </list> </property> </bean> I also need to load all the localized messages so I have made my own class for it: public class ErpMessageSource extends ResourceBundleMessageSource { public Map<String, String> getMessages(String basename, Locale locale)