• struct2(一)第一个struct程序


    说明:本系列是针对struct2学习过程,主要的目的:

    1. 探索针对一个新的开源框架的学习过程。

    2. 学习struct2,学习官方对struct2介绍的方法。

    3.别把英语忘了。

    1. 为了更加清晰的明白struct工程每个文件的意义,我们新建的是一个普通的java工程。

    image

    这个工程使用jetty直接调试,这样比较的方便,具体的见:jetty直接调试

    需要注意的是:

    WebAppContext webapp = new WebAppContext("WebRootFile", "/struct2"); 

    文件名和工程名,与在建立工程的文件名和工程名称一样,就好。

    测试工程:

    image

    ok了,准备工作完成。

    添加struct2的支持,这个都比较的简单,直接贴张图吧。

    image

    下面的步骤,struct2的官方教程:

    web.xml为:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" 
        xmlns="http://java.sun.com/xml/ns/javaee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
        http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
      <display-name></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>*.action</url-pattern>
      </filter-mapping>
    </web-app>

    structs.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>
       <constant name="struts.devMode" value="true" />
     
        <package name="basicstruts2" extends="struts-default">
     
            <action name="index">
                <result>/index.jsp</result>
            </action>
     
        </package>
    </struts>

    ok,第一个struct完成。但是没有什么展示的效果比较的不能说明问题,下一步我们加一点展示的内容。

  • 相关阅读:
    HTML CSS整理笔记
    2020软件工程最后一次作业
    form表单的基本用法
    图片预加载和懒加载(2)——懒加载
    ES6——promise基础
    图片预加载和懒加载(2)——预加载
    图片预加载和懒加载(1)
    js时间——转换为我们需要的格式
    原生js瀑布流
    富文本——小程序中使用特殊符号及标签
  • 原文地址:https://www.cnblogs.com/zhailzh/p/3987567.html
Copyright © 2020-2023  润新知