• struts2.2.3使用总结


    最少所需jar包

    struts.xml

    <?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" /> <package
    name="default" namespace="/" extends="struts-default">

    <default-action-ref name="index" /> <global-results> <result
    name="error">/error.jsp</result> </global-results>

    <global-exception-mappings> <exception-mapping
    exception="java.lang.Exception" result="error"/>
    </global-exception-mappings> <action name="index"> <result
    type="redirectAction"> <param name="actionName">HelloWorld</param>
    <param name="namespace">/example</param> </result> </action>
    </package> <include file="example.xml"/>
    -->

    <package name="registration" namespace="/" extends="struts-default">
    <action name="u" class="u">
    <result name="success">/registerSuccess.jsp</result>
    <result name="fail">/registerFail.jsp</result>
    <result name="list">/userlist.jsp</result>
    <result name="load">/user.jsp</result>
    </action>
    </package>

    </struts>

      

    web.xml

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


    <display-name>User registration</display-name>


    <!-- 把session的关闭延迟到jsp页面显示之后,在配在struts2上面。 -->
    <filter>
    <filter-name>OpenSessionInView</filter-name>
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>OpenSessionInView</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>



    <!-- 使用spring过滤器解决中文乱码问题 -->
    <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
    <param-name>encoding</param-name>
    <param-value>GBK</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>



    <!-- 使用struts2必须有的配置 -->
    <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>


    <!-- spring 与 struts2 整合时需要的配置 ,实现在action中依赖注入功能-->
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <!-- <param-value>/WEB-INF/daoContext.xml /WEB-INF/applicationContext.xml</param-value>-->
    <param-value>classpath:beans.xml</param-value>
    </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


    </web-app>

      

  • 相关阅读:
    python常用模块
    清除在Windows下访问共享文件夹时的登录信息
    CentOS 6.3下Samba服务器的安装与配置
    textarea定位光标
    js中apply方法的使用
    js call方法
    linux 安装svn,并设置钩子来同步更新
    mysql给root开启远程访问权限,修改root密码
    在VMware的Linux系统上安装Redis
    (转)NoSQL——Redis在win7下安装配置的学习一
  • 原文地址:https://www.cnblogs.com/zfc2201/p/2143477.html
Copyright © 2020-2023  润新知