Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't access attribute in request?

Tags:

struts2

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?

like image 876
hiway Avatar asked Feb 01 '26 03:02

hiway


1 Answers

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="/"/>
like image 83
Aleksandr M Avatar answered Feb 03 '26 10:02

Aleksandr M