Struts学习及面试应用

来源:互联网 发布:淘宝做活动怎么做 编辑:程序博客网 时间:2024/06/02 05:56

1、最好的学习的地方就是官网

        http://struts.apache.org

2、概述 

       Apache Struts 2 is an elegant, extensible framework for creating enterprise-ready Java web applications. The framework is designed to streamline the full development cycle, from building, to deploying, to maintaining applications over time.

Apache Struts 2 was originally known as WebWork 2. After working independently for several years, the WebWork and Struts communities joined forces to create Struts2. This new version of Struts is simpler to use and closer to how Struts was always meant to be. 

      Apache Struts 2 是一个为企业级应用打造的优秀的、可扩展的Web框架。该框架旨在充分精简应用程序的开发周期,从而减少创建、发布、应用所花费的时间。

3、开发的步骤如下

        (1)、下载Struts 2 框架;

        (2)、创建Web Project;

        (3)、加载Struts 2包;

        (4)、修改web.xml;

        (5)、创建login.jsp

        (6)、实现控制器

        (7)、配置struts.xml;

        (8)、创建登录成功、失败页面;

        (9)、部署


4、ActionContext ,servletContext,PageContext的区别

     ActionContext是当前action的上下文环境,通过ActionContext 可以获取到request,session.ServletContext等与Action有关的对象应用。

     servletContext是域对象,一个web应用中只有一个ServletContext,生命周期伴随着整个web应用。

     PageContext是JSP的一个重要的内置对象,可以通过poageContext 获取到其他域对象的应用,同时他是一个域对象,作用范围只针对四个域对象中最小的。

5、result的type属性中有哪几种结果类型?

Struts2框架提供的结果类型

已配置结果类型名 类 名 描 述dispatcher org.apache.struts2.dispatcher.
ServletDispatcherResult 默认结果类型,用来呈现JSP页面chain com.opensymphony.xwork2.
ActionChainResult 将action和另外一个action链接起来freemarker org.apache.struts2.views.freemarker.
FreemarkerResult 呈现Freemarker模板httpheader org.apache.struts2.dispatcher.
HttpHeaderResult 返回一个已配置好的HTTP头信息响应redirect org.apache.struts2.dispatcher.
ServletRedirectResult 将用户重定向到一个已配置好的URLredirectAction org.apache.struts2.dispatcher.
ServletActionRedirectResult 将用户重定向到一个已定义好的actionstream org.apache.struts2.dispatcher.
StreamResult 将原始数据作为流传递回浏览器端,
该结果类型对下载的内容和图片非常有用velocity org.apache.struts2.dispatcher.
VelocityResult 呈现Velocity模板xslt org.apache.struts2.views.xslt.
XSLTResult 呈现XML到浏览器
该XML可以通过XSL模板进行转换plaintext org.apache.struts2.dispatcher.
PlainTextResult 返回普通文本类容

    

 

     



     



   


0 0
原创粉丝点击