• struts2学习笔记之二_在项目中引入struts2


    在项目中引入struts2

    1.创建web项目
    2.引入struts2类库
      ${struts解压目录}/app/struts2-blank-2.1.8.1.war/web-inf/lib/*.jar
    3.创建action.
      package cn.itcast.struts2.action/*** HelloWorldAction*/

      public class HelloWorldAction {
        public String execute(){
        System.out.println("hello world");
        return null ;
        }
      }
    4.创建struts配置文件.src/struts.xml
      dtd:struts-core.jar/struts-2.1.7.dtd/30行
      <?xml version="1.0"?>
      <!DOCTYPE struts PUBLIC
      "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
      "http://struts.apache.org/dtds/struts-2.1.7.dtd">
      <struts>
        <package name="HelloWorldPkg" namespace="/helloworld">
        <action name="HelloWorldAction"             

            class="cn.itcast.struts2.action.HelloWorldAction" />
        </package>
      </struts>
    5.配置struts2的过滤器web-inf/web.xml文件中
    类:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
    <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      <filter>
        <filter-name>action</filter-name>
      <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
      </filter>
      <filter-mapping>
        <filter-name>action</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>

      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
    </web-app>

  • 相关阅读:
    Content Hugging Priority 和 Content Compression Resistance Priority
    fiddler 拦截小结
    好的 iOS 代码习惯
    查看约束优先级的方法
    定义接口常用约定
    让系统照片选择器的导航栏变蓝的代码
    ZT C语言实现字符串倒序
    ZT 蓝牙的AVCTP协议笔记
    ZT 蓝牙的AVDTP协议笔记
    ZT A2DP协议笔记
  • 原文地址:https://www.cnblogs.com/avrilliu/p/3238049.html
Copyright © 2020-2023  润新知