Skip to content

itzg/try-spring-mvc-view-customizing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This application tries out two aspects of customizing Spring MVC view customization

  • Directing requests with a particular prefix (/greeting) to the index.html
  • Processing requests for a specific content type (text/plain) with a custom view

Scenarios

Invoking

curl localhost:8080
curl localhost:8080/greeting
curl localhost:8080/greeting/human

Gives

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Greetings</title>
</head>
<body>

Greetings, this view works.

</body>
</html>

Invoking

curl -H "Accept: plain/text" localhost:8080/greeting

Gives

Some plain text for the request view '/index.html'

Invoking

curl localhost:8080/api/currentTime

Gives

<html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Wed Jan 16 16:00:26 CST 2019</div><div>There was an unexpected error (type=Not Acceptable, status=406).</div><div>Could not find acceptable representation</div></body></html>

Invoking

curl -H "Accept: application/json" localhost:8080/api/currentTime

Gives

{"time":"Wed Jan 16 16:00:40 CST 2019"}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published