随笔 - 45, 文章 - 6, 评论 - 4, 引用 - 0
数据加载中……

struts2应用程序结构

 程序目录结构

project

-JSP

-WEB-INF

  - src

  - classes

    - struts.xml

    - struts.properties

  - lib

  - build.xml

  - applicationContext.xml

  - web.xml

 

-lib目录下放置struts2的开发包,包含struts2所依懒的包,也可以是程序开发后打包的结果

-src自开发程序(原码目录)

 

 

---------------------web.xml-----------------------

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

    <display-name>Struts Blank</display-name>

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
   

    <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>/WEB-INF/applicationContext.xml</param-value>
     </context-param>


    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>  

</web-app>

1配置了struts2拦截机

2加入spring载入侦听

 

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

    <package name="default" extends="struts-default">

        <action name="Login" class="LoginAction">
            <result name="success">/welcome.jsp</result>
            <result name="error">/error.jsp</result>
        </action>

    </package>

 

配置了一个包,定义了一个action和两个结果

 

 

---------------------------struts.properties-------------

struts.i18n.encoding=GBK

 

定义了默认的编码规则

posted on 2009-05-01 09:29 liyang 阅读(656) 评论(0)  编辑  收藏 所属分类: apache