简体   繁体   中英

ServletActionContext for struts2 + spring MVC

I want to change this struts 2 code to spring MVC, does anyone have a clue?

HttpServletRequest request = ServletActionContext.getRequest();

I am getting this

org.apache.struts2.dispatcher.StrutsRequestWrappe@3535

while it hits a struts2 web app and this :

 FirewalledRequest[ org.apache.catalina.connector.RequestFacade@2425]

while hitting a spring MVC web app. I am a bit confused. Any suggestions will help

You can use this code to access the HttpServletRequest request in spring.

ServletRequestAttributes attr = (ServletRequestAttributes)
                                RequestContextHolder.currentRequestAttributes();
HttpServletRequest request = attr.getRequest();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM