zoukankan      html  css  js  c++  java
  • 【Struts2复习知识点一】配置struts2环境

    1.添加struts2支持包到lib目录下。

    2.创建struts.xml文件并放到src目录下。

    View Code
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd"
    >

    <struts>
    <!--
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />

    <include file="example.xml"/>



    <package name="default" namespace="/" extends="struts-default">
    <default-action-ref name="index" />
    <action name="index">
    <result type="redirectAction">
    <param name="actionName">HelloWorld</param>
    <param name="namespace">/example</param>
    </result>
    </action>
    </package>
    -->

    <!--即时加载-->
    <constant name="struts.devMode" value="true" />
    <package name="default" namespace="/" extends="struts-default">

    <action name="hello">
    <result>
    /Hello.jsp
    </result>
    </action>
    </package>
    <!-- Add packages here -->

    </struts>


     3.配置web.xml文件

    View Code
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5"
    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_2_5.xsd"
    >
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <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>

     4. 访问 http://localhost:8080/projectrname/hello 即可查看Hello.jsp

    注意:tomcat安装路径不能有空格。负责启动报错。

  • 相关阅读:
    配置Python3 Pip3环境变量
    超级搜索术-读书笔记
    技术笔记-图片管理器
    Python不错的资料、网站
    输入法9键 VS 26键,哪个更适合?
    超级搜索术-思维导图
    Linux知识-Docker
    Python知识体系-基础知识03-函数/类/模块
    js基础(BOM对象)
    js基础(事件)
  • 原文地址:https://www.cnblogs.com/surge/p/2362004.html
Copyright © 2011-2022 走看看