Home >Database >Mysql Tutorial >structs2 初次配置

structs2 初次配置

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 15:14:551284browse

本文分为structs2的配置 和 structs2框架下程序(hello structs)的运行。 1 配置structs 1 新建dynamic web project: hellostructs 2 从官网下载完整的structs2 文件夹 3 将structs文件下app下的structs2-blank.war 用winrar解压 4 将structs-blank\WEB-IN

本文分为structs2的配置 和  structs2框架下程序(hello structs)的运行。


1   配置structs

     1 新建dynamic web project: hellostructs

     2 从官网下载完整的structs2 文件夹

     3 将structs文件下app下的structs2-blank.war 用winrar解压

     4  将structs-blank\WEB-INF\classes的structs.xml 复制到项目的src文件夹下

     5  struts2-blank\WEB-INF\lib 中的解压文件复制到项目WEB-INF\lib文件夹中

     6   把struts2-blank\WEB-INF 下 web.xml文件中部分内容复制到羡慕xml 文件中(如welcome模块下)


2  将项目调整为适应structs2的设置

    1  注释掉 structs.xml文件中 中的原本内容。

    2  将其中的package部分复制,粘贴到structs模块中。 package中包括如下内容:

  

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

        <default-action-ref name="index"></default-action-ref>

        <global-results>
            <result name="error">/error.jsp</result>
        </global-results>

        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception" result="error"></exception-mapping>
        </global-exception-mappings>

        <action name="index">
            <result type="redirectAction">
                <param name="actionName">HelloWorld
                <param name="namespace">/example
            </result>
        </action>
    </package>
将其修改为如下内容:
<package name="default" namespace="/" extends="struts-default">

       
        <global-results>
            <result name="error">/error.jsp</result>
        </global-results>

        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception" result="error"></exception-mapping>
        </global-exception-mappings>

        <action name="hello">
            <result>
                /Hello.jsp
            </result>
        </action>
    </package>

项目中建立jsp文件 Hello.jsp.  body中内容填写 Hello structs2!


至此,运行此jsp文件,将可以显示 Hello structs2!


但是如果直接运行项目文件,将无法访问到该jsp。 需要修改xml文件,增加内容:

 Hello.jsp

   另外,为了使对项目的修改不至于重启服务器才能生效, 需将项目配置在开发模式。

  复制struct文件中内容 到structs模块中

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn