spring-framework / org.springframework.web.servlet.mvc / UrlFilenameViewController

UrlFilenameViewController

open class UrlFilenameViewController : AbstractUrlViewController

Simple Controller implementation that transforms the virtual path of a URL into a view name and returns that view.

Can optionally prepend a prefix and/or append a suffix to build the viewname from the URL filename.

Find some examples below:

  1. "/index" -> "index"
  2. "/index.html" -> "index"
  3. "/index.html" + prefix "pre_" and suffix "_suf" -> "pre_index_suf"
  4. "/products/view.html" -> "products/view"

Thanks to David Barri for suggesting prefix/suffix support!

Author
Alef Arendsen

Author
Juergen Hoeller

Author
Rob Harrop

See Also
#setPrefix#setSuffix

Constructors

<init>

UrlFilenameViewController()

Simple Controller implementation that transforms the virtual path of a URL into a view name and returns that view.

Can optionally prepend a prefix and/or append a suffix to build the viewname from the URL filename.

Find some examples below:

  1. "/index" -> "index"
  2. "/index.html" -> "index"
  3. "/index.html" + prefix "pre_" and suffix "_suf" -> "pre_index_suf"
  4. "/products/view.html" -> "products/view"

Thanks to David Barri for suggesting prefix/suffix support!

Functions

setPrefix

open fun setPrefix(prefix: String): Unit

Set the prefix to prepend to the request URL filename to build a view name.

setSuffix

open fun setSuffix(suffix: String): Unit

Set the suffix to append to the request URL filename to build a view name.