我用velocity时,在dispatch-servlet中配置
<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"><property name="exposeRequestAttributes" value="true"></property>
<property name="exposeSessionAttributes" value="true"></property>可以访问到request和session
<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"><property name="exposeRequestAttributes" value="true"></property>
<property name="exposeSessionAttributes" value="true"></property>可以访问到request和session
然后Session,request随便你用了
import com.opensymphony.xwork2.ActionContext;
倒的是这个包,别倒错了
Action.getServlet();
得到的Servlet是ActionServlet,也就是说他并非单纯的Servlet;
相反的,如果用springMVC来得到Servlet的功能,一般可以使用:
req.getSession().getServletContext();
得到的ServletContext基本可以完成任何的Servlet的功能;