Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access request parameters from a JSP View in Spring Web MVC without putting them in a model

I'd like to be able to access some HTTP GET parameters directly in a JSP, without having to pass them through a Controller+Model, but at the same time still use the dispatcher/controller/model/view mechanism for other parameters and logic.

This is because I have many HTTP GET parameters that are generated by Javascript and used also only in Javascript. My Controllers don't need them at all.

I tried ${arg}, ${request.arg}, ${requestScope.arg}, nothing seems to work.

If I bypass the dispatcher, ${requestScope.arg} works.

But is there a way to make it work with the dispatcher?

Thanks!

like image 450
rustyx Avatar asked Jan 23 '12 21:01

rustyx


1 Answers

If that's request parameters that you want to access (and not request attributes like the title says), then the syntax is ${param.parameterName}.

If it's request attributes, then it's ${requestScope.attributeName}.

See http://java.sun.com/products/jsp/syntax/2.0/syntaxref207.html#1010522 for a quick reference.

like image 122
JB Nizet Avatar answered Oct 03 '22 01:10

JB Nizet