2017-02-19 31 views
-1

我在運行我的程序時出現上述錯誤。我是Struts 1.x的新手。如何在Eclipse中解決這個問題?我正在使用Weblogic服務器。錯誤500 - 內部服務器錯誤javax.servlet.jsp.JspException:無法檢索作用/寄存器映射

的struts-config.xml

<?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-soucres> 
<set-property property="username" value="navneet"/> 
<set-property property="password" value="navi123"/> 
</data-soucres> 
<form-beans> 
    <form-bean name="RegisterForm" type="com.navi.forms.RegisterForm" /> 
</form-beans> 

<action-mapping> 
    <action name="RegisterForm" path="/register" type="com.navi.actions.RegisterAction" validate="true" scope="request" input="/register.jsp" > 
    <forward name="success" path="/success.jsp" /> 
    </action> 
</action-mapping> 
</struts-config> 

的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> 
    <display-name>RegisterExample</display-name> 
    <servlet> 
    <servlet-name>action</servlet-name> 
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> 
    <init-param> 
    <param-name>config</param-name> 
    <param-value>/WEB-INF/struts-config.xml</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>action</servlet-name> 
    <url-pattern>*.do</url-pattern> 
    </servlet-mapping> 

    <welcome-file-list> 
    <welcome-file>register.jsp</welcome-file> 
    </welcome-file-list> 

    <jsp-config> 
    <taglib> 
     <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri> 
     <taglib-location>/WEB-INF/struts-html.tld</taglib-location> 
    </taglib> 
    </jsp-config> 
</web-app> 

register.jsp

<html:html> 
<html:form action="register.do" method="post"> 
username:<html:text property="username"></html:text> 
password:<html:text property="password"></html:text><br> 
<html:submit/> 
</html:form> 
</html:html> 

enter image description here

+1

出於興趣,當你寫'新的Struts'時,你的意思是'我是Struts'的新手嗎?額外的角色是否需要付出很多努力? – halfer

回答

0

在你的JSP,形式action參數必須符合行動的path在動作映射:

struts-config.xml中

<action name="RegisterForm" path="/register" ... > 
    ... 
</action> 

register.jsp

<html:form action="/register" ... > 
    ... 
</html:form>