日期:2014-05-17  浏览次数:20715 次

求助:struts1.1配置问题
初学框架,虽然2比较好用,但是听说从1学起比较好,然后配置XML就出现问题了,帮我看一下。谢谢。
Java code
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"<jsp-config>
<taglib>
<taglib-url>/WEB-INF/struts-bean.tld</taglib-url>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-url>/WEB-INF/struts-html.tld</taglib-url>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-url>/WEB-INF/struts-logic.tld</taglib-url>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</jsp-config>

</web-app>


开始没加<jsp-config> taglib报错,现在加了后,taglib-url报错,求解 - -听说和version有关,我的是2.5.。

------解决方案--------------------
XML code

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

<struts-config>
    <data-sources />
    <form-beans>
        <form-bean name="publicFrom"
            type="org.apache.struts.validator.DynaValidatorActionForm">
            <form-property name="title" type="java.lang.String" />
        </form-bean>
    </form-beans>
    <global-exceptions />
    <global-forwards>
        <forward name="login" path="/login.jsp" />
    </global-forwards>
    <action-mappings>
        <!-- 登录 -->
        <action path="/login"
            type="org.springframework.web.struts.DelegatingActionProxy"
            name="publicFrom" scope="request" parameter="method">
            <forward name="success" path="/index.jsp" />
            <forward name="login" path="/login.jsp" />
        </action>
    </action-mappings>

    <message-resources parameter="com.un.struts.ApplicationResources" />
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames"
            value="/WEB-INF/validator/validator-rules.xml,/WEB-INF/validator/validation.xml" />
    </plug-in>
</struts-config>

------解决方案--------------------
上面的 struts-config.xml

下面是web.xml

XML code

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    
    <servlet>
        <servlet-name>log4j-init</servlet-name>
        <servlet-class>com.un.filter.Log4jInit</servlet-class>
        <init-param>
            <param-name>log4j</param-name>
            <param-value>WEB-INF/classes/log4j.properties</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- sping配置  -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
        /WEB-INF/config/spring/applicationContext-service.xml
        </param-valu