zoukankan      html  css  js  c++  java
  • 初学Structs配置及其注意事项

    刚开始接触Structs,配置过程及其各种出现的错误,整整弄了好长时间,为了防止以后又忘记,所以在这里简单的记录下。

    首先,新建一个web项目,在web下导入jar包,然后,配置struct.xml,具体代码如下

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
        "http://struts.apache.org/dtds/struts-2.3.dtd">
    <struts>
    <constant value="false" name="struts.enable.DynamicMethodInvocation"/>
    <constant value="true" name="struts.devMode"/>
        <package name="struts2" extends="struts-default" namespace="/">
            <action name="Login" class="net.hncu.struct2.action.LoginAction"><!--注意这里的action name="Login",一般为大写,这是为了和后面的主页面的<form action="Login.action">相对应--!>
                <result name="success">/login_success.jsp</result><!--此处为跳转下一个页面!-->
                <result name="failure">/login_failure.jsp</result>
            </action>
        </package>
    </struts>

    然后配置web.xml,代码如下:

    	<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>
    	<welcome-file-list>
    		<welcome-file>login.jsp</welcome-file>
    

     将此处的代码复制到web.xml下面,完成配置 

  • 相关阅读:
    [USACO12FEB]牛券Cow Coupons
    合并果子
    序列合并
    中位数
    道路游戏
    教主的花园
    摆花
    hello world之Makefile
    mysql+tomcat+spring 配置心得(从0开始搭环境)
    C#,.Net自动生成大写字母编码
  • 原文地址:https://www.cnblogs.com/FENGXUUEILIN/p/5125990.html
Copyright © 2011-2022 走看看