Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
setup-project
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EAR
setup-project
Commits
f3efd27f
Commit
f3efd27f
authored
8 years ago
by
Martin Ledvinka
Browse files
Options
Downloads
Patches
Plain Diff
Simplified application configuration.
parent
096ef9b4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/cz/cvut/kbss/ear/setup/config/RestConfig.java
+2
-0
2 additions, 0 deletions
src/main/java/cz/cvut/kbss/ear/setup/config/RestConfig.java
src/main/java/cz/cvut/kbss/ear/setup/config/WebAppConfig.java
+3
-30
3 additions, 30 deletions
...main/java/cz/cvut/kbss/ear/setup/config/WebAppConfig.java
with
5 additions
and
30 deletions
src/main/java/cz/cvut/kbss/ear/setup/config/RestConfig.java
+
2
−
0
View file @
f3efd27f
...
...
@@ -14,6 +14,7 @@
*/
package
cz.cvut.kbss.ear.setup.config
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -27,6 +28,7 @@ public class RestConfig {
@Bean
public
ObjectMapper
objectMapper
()
{
final
ObjectMapper
objectMapper
=
new
ObjectMapper
();
objectMapper
.
setSerializationInclusion
(
JsonInclude
.
Include
.
NON_NULL
);
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
return
objectMapper
;
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/cz/cvut/kbss/ear/setup/config/WebAppConfig.java
+
3
−
30
View file @
f3efd27f
...
...
@@ -14,23 +14,16 @@
*/
package
cz.cvut.kbss.ear.setup.config
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.
context
.annotation.
Bean
;
import
org.springframework.
beans.factory
.annotation.
Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
;
import
org.springframework.web.multipart.MultipartResolver
;
import
org.springframework.web.multipart.support.StandardServletMultipartResolver
;
import
org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
org.springframework.web.servlet.view.InternalResourceViewResolver
;
import
org.springframework.web.servlet.view.JstlView
;
import
java.nio.charset.Charset
;
import
java.util.List
;
...
...
@@ -40,37 +33,17 @@ import java.util.List;
@Import
({
RestConfig
.
class
})
public
class
WebAppConfig
extends
WebMvcConfigurerAdapter
{
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
registry
.
addResourceHandler
(
"/resources/**"
).
addResourceLocations
(
"/resources/"
);
registry
.
addResourceHandler
(
"/js/**"
).
addResourceLocations
(
"/js/"
);
}
@Autowired
private
ObjectMapper
objectMapper
;
@Override
public
void
configureDefaultServletHandling
(
DefaultServletHandlerConfigurer
configurer
)
{
configurer
.
enable
();
}
@Bean
public
InternalResourceViewResolver
setupViewResolver
()
{
InternalResourceViewResolver
resolver
=
new
InternalResourceViewResolver
();
resolver
.
setViewClass
(
JstlView
.
class
);
resolver
.
setPrefix
(
"/WEB-INF/"
);
resolver
.
setSuffix
(
".html"
);
return
resolver
;
}
@Bean
(
name
=
"multipartResolver"
)
public
MultipartResolver
multipartResolver
()
{
return
new
StandardServletMultipartResolver
();
}
@Override
public
void
configureMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
)
{
final
MappingJackson2HttpMessageConverter
converter
=
new
MappingJackson2HttpMessageConverter
();
final
ObjectMapper
objectMapper
=
new
ObjectMapper
();
objectMapper
.
setSerializationInclusion
(
JsonInclude
.
Include
.
NON_NULL
);
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
converter
.
setObjectMapper
(
objectMapper
);
converters
.
add
(
converter
);
final
StringHttpMessageConverter
stringConverter
=
new
StringHttpMessageConverter
(
Charset
.
forName
(
"UTF-8"
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment