zoukankan      html  css  js  c++  java
  • struts2_20140720

          有这样的感觉:前面学的东西弄会了,过了一段时间又感觉陌生了,还要重新开始。这次想个好办法,把写的程序用博客记录下来,把自己的学历历程用博客的形式呈现出来,一来可以方便复习,而来可以以后开发程序可以快速上手,而且代码有快速参考价值。

         struts 2第一节:

         第一步:新建web project,默认index.jsp.

         第二步:在src目录下,新建(或者从struts包中拷贝)struts.xml文件。导入类库。struts.xml代码:

                       

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
    <struts>
      
      <package name="myPackage" extends="struts-default">
          <action name="first">
             <result>
                 /first.jsp
             </result>
          </action>
      </package>
      
    </struts>    

      第三步:web.xml文件更改:

      

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
      <display-name>struts2_20140720</display-name>
      <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
      </filter>
      <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
    </web-app>

        第二步和第三步在myeclipse中可以自动完成。选定工程名称-->右键--->myeclipse--->project-facets--->install apache struts 2

         第三步:index.jsp中添加链接标签

        

    <a href="first.action">struts.2</a>

    第四步:新建first.jsp

    部署,ok!

         

  • 相关阅读:
    毕业五年后的差距
    基于jsonlib.jar包Json程序 实战篇
    Hashtable
    [转]浏览器是怎样工作的:渲染引擎,HTML解析
    Web.config之连接字介绍
    jQuery选择器全解【转】
    JavaScript document属性和方法
    zoj 2316 Matrix Multiplication 夜
    zoj 2318 Get Out! 夜
    hdu 3666 THE MATRIX PROBLEM 夜
  • 原文地址:https://www.cnblogs.com/yaopan007/p/3857373.html
Copyright © 2011-2022 走看看