gpt4 book ai didi

java - HTTP 状态 500 - Struts1 中的路径没有操作实例

转载 作者:行者123 更新时间:2023-12-01 04:57:46 27 4
gpt4 key购买 nike

这是我第一次使用 Struts,我构建了一个非常简单的程序
但我总是遇到这个错误:(
我已经用谷歌搜索了两天,但我的类型肯定是正确的。这是我的代码:

web.xml

    <?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<filter>
<filter-name>SetCharacterEncoding</filter-name>
<filter-class>tw.com.whichone.filter.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SetCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>whichone</filter-name>
<filter-class>tw.com.whichone.filter.CheckParameter</filter-class>
</filter>
<filter-mapping>
<filter-name>whichone</filter-name>
<url-pattern>*.whichone</url-pattern>
</filter-mapping>


<!-- Standard Action Servlet Configuration (with debugging) -->
<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/conf/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- servlet-mapping -->

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>


<taglib>
<taglib-uri>http://jakarta.apache.org/struts/tags-bean</taglib-uri>
<taglib-location>/WEB-INF/tlds/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://jakarta.apache.org/struts/tags-logic</taglib-uri>
<taglib-location>/WEB-INF/tlds/struts-logic.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://jakarta.apache.org/struts/tags-html</taglib-uri>
<taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://jakarta.apache.org/struts/tags-nested</taglib-uri>
<taglib-location>/WEB-INF/tlds/struts-nested.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>http://jakarta.apache.org/struts/tags-tiles</taglib-uri>
<taglib-location>/WEB-INF/tlds/struts-tiles.tld</taglib-location>
</taglib>


struts-config

    <?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>
<form-beans>
<form-bean type="org.apache.struts.action.DynaActionForm"
name="Store_Data">
<form-property type="java.lang.String" name="one" />
<form-property type="java.lang.String" name="StoreSeqNo" />
<form-property type="java.lang.String" name="StoreName" />
<form-property type="java.lang.String" name="StoreOwner" />
<form-property type="java.lang.String" name="StoreAddress" />
<form-property type="java.lang.String" name="StorePhone" />
<form-property type="java.lang.String" name="StoreOpenDate" />

<!-- "回首頁"連結清session專用變數 -->
<form-property type="java.lang.String" name="CleanSession" />
</form-bean>
</form-beans>

<global-forwards>
<forward path="/success.html" name="Success" />
<forward path="/error.html" name="Error" />
</global-forwards>

<action-mappings>
<action path="/Store_Data_Parised" type="action.Store_Data_Parised"
name="Store_Data" scope="request" validate="false" parameter="one">
</action>
</action-mappings>


<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" />
<message-resources parameter="MessageResources" />
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"
/>
<set-property property="moduleAware" value="true" />
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
</struts-config>

index.html

    <html>
<head>
<title>Test Page</title>
</head>


<body>
<form action="Store_Data_Parised.do?one=insert">
<hr></hr>
<h3>Add new store</h3>
<table border="1" bordercolor="black">
<tr>
<td align="right">Store Name:</td>
<td colspan="3"><input type="text" name="StoreName"
maxlength="20" /></td>
</tr>
<tr>
</table>

<table border="1" bordercolor="black">
<tr>
<td align="right">Store Owner:</td>
<td colspan="3"><input type="text" name="StoreOwner"
maxlength="20" /></td>
</tr>
<tr>
</table>

<table border="1" bordercolor="black">
<tr>
<td align="right">Store Address:</td>
<td colspan="3"><input type="text" name="StoreAddress"
maxlength="20" /></td>
</tr>
<tr>
</table>

<table border="1" bordercolor="black">
<tr>
<td align="right">Store Phone:</td>
<td colspan="3"><input type="text" name="StorePhone"
maxlength="20" /></td>
</tr>
<tr>
</table>

<table border="1" bordercolor="black">
<tr>
<td align="right">OpenDate:</td>
<td colspan="3"><input type="text" name="StoreOpenDate"
maxlength="20" /></td>
</tr>
<tr>
</table>
<hr></hr>
<input type="submit" value="Add" />

</form>
</body>
</html>

Store_Data_Parished.java



 公共(public)类 Store_Data_Parished {

public ActionForward insert(ActionMapping 映射, ActionForm 表单,
HttpServletRequest 请求,HttpServletResponse 响应)
抛出异常{

DynaActionForm 表单 = (DynaActionForm) 表单;
字符串一 = (字符串) Form.get("一");
String StoreName = (String) Form.get("StoreName");
String StoreOwner = (String) Form.get("StoreOwner");
String StoreAddress = (String) Form.get("StoreAddress");
String StorePhone = (String) Form.get("StorePhone");
String StoreOpenDate = (String) Form.get("StoreOpenDate");

尝试 {

映射条件 = new HashMap();
criteria.put("商店名称", 商店名称);
criteria.put("StoreOwner", StoreOwner);
criteria.put("StoreAddress", StoreAddress);
criteria.put("StorePhone", StorePhone);
criteria.put("StoreOpenDate", StoreOpenDate);

Store_Data_handler.insert(标准);

} catch (异常 e) {

返回映射.findForward(“错误”);
}
return 映射.findForward("成功");
}

}

最佳答案

该类需要使用“Action”进行扩展例如:公共(public)类 Store_Data_Parished 扩展 Action

关于java - HTTP 状态 500 - Struts1 中的路径没有操作实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13813589/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com