security and rest work

This commit is contained in:
eparaschiv 2013-06-02 20:45:26 +03:00
parent 0eea508ede
commit 79269f8a43
6 changed files with 260 additions and 226 deletions

View File

@ -9,11 +9,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView; import org.springframework.web.servlet.view.JstlView;
@EnableWebMvc
@Configuration @Configuration
public class FrontendConfig extends WebMvcConfigurerAdapter { @EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
public FrontendConfig() { public MvcConfig() {
super(); super();
} }

View File

@ -6,7 +6,7 @@
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0"> id="WebApp_ID" version="3.0">
<display-name>Spring MVC Application</display-name> <display-name>Spring Security Basic Auth Application</display-name>
<!-- Spring root --> <!-- Spring root -->
<context-param> <context-param>

View File

@ -1,4 +1,5 @@
<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"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>org.baeldung</groupId> <groupId>org.baeldung</groupId>
<artifactId>spring-security-custom</artifactId> <artifactId>spring-security-custom</artifactId>
@ -71,6 +72,20 @@
<version>${org.springframework.version}</version> <version>${org.springframework.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- marshalling -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.2</version>
</dependency>
<!-- web --> <!-- web -->
<dependency> <dependency>

View File

@ -1,10 +1,16 @@
package org.baeldung.spring; package org.baeldung.spring;
import java.util.List;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration @Configuration
@EnableWebMvc
@ComponentScan("org.baeldung.web") @ComponentScan("org.baeldung.web")
public class WebConfig extends WebMvcConfigurerAdapter { public class WebConfig extends WebMvcConfigurerAdapter {
@ -12,6 +18,14 @@ public class WebConfig extends WebMvcConfigurerAdapter {
super(); super();
} }
// API // beans
@Override
public void configureMessageConverters(final List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);
converters.add(new MappingJackson2HttpMessageConverter());
}
//
} }

View File

@ -2,6 +2,9 @@ package org.baeldung.web.dto;
import java.io.Serializable; import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Foo implements Serializable { public class Foo implements Serializable {
public Foo() { public Foo() {

View File

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation=" xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>Spring MVC Application</display-name> <display-name>Spring Security Custom Application</display-name>
<!-- Spring root --> <!-- Spring root -->
<context-param> <context-param>
@ -43,8 +45,8 @@
<url-pattern>/*</url-pattern> <url-pattern>/*</url-pattern>
</filter-mapping> </filter-mapping>
<!-- <welcome-file-list> --> <welcome-file-list>
<!-- <welcome-file>index.html</welcome-file> --> <welcome-file>index.html</welcome-file>
<!-- </welcome-file-list> --> </welcome-file-list>
</web-app> </web-app>