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!

         

  • 相关阅读:
    php 中ASCII编码的使用
    BASE64
    微信公众平台--6.JS-SDK 微信内网页开发工具包
    python3中zipfile模块的常用方法
    python3开发进阶-Django框架学习前的小项目(一个简单的学员管理系统)
    python3开发进阶-Django框架的起飞加速一(ORM)
    python3开发进阶-Django框架起飞前的准备
    python3开发进阶-Web框架的前奏
    前端基础-jQuery的最常用的的方法each、data、
    前端基础-jQuery的动画效果
  • 原文地址:https://www.cnblogs.com/yaopan007/p/3857373.html
Copyright © 2011-2022 走看看