hiway
hiway

Reputation: 3976

Why can't access attribute in request?

I want to access some attributes in request, for example, the base attribute in request, the following are part of values in request

 request    ...base=/ecs, stack=com.opensymphony.xwork2.ognl.OgnlValueStack@11c4b31}, __cleanup_recursion_counter=1, .freemarker.RequestParameters=freemarker.ext.servlet.HttpRequestParametersHashModel@1c00cb4 ...

I use <s:debug /><s:property value="%{#request.base}" /> to access base attribute in request, but nothing shown in my jsp. So why?

Upvotes: 3

Views: 1422

Answers (2)

Aleksandr M
Aleksandr M

Reputation: 24406

Not sure why do you need this but only base inside request is inside .freemarker.TemplateModel which is ScopesHashModel. So you need use method get to get things from there.

<s:property value="#request['.freemarker.TemplateModel'].get('base')" />

Try this:

<s:property value="#request['javax.servlet.include.context_path']"/>

Update

If you just need context path then use <s:url> tag for that.

<s:url value="/"/>

Upvotes: 3

Dev Blanked
Dev Blanked

Reputation: 8885

If you want to access request parameters following will work

<s:property value="#parameters['base']"/>

If you want to access attributes of the request then following should work

<s:property value="#request.base"/>

or

<s:property value="#request['base']" />

Upvotes: -1

Related Questions