struts 1.1:调度操作错误:错误 400 请求中没有参数
为了在一个表单上执行多个操作,我使用了dispatchAction。 我从一个孤独的操作开始,当我将标准操作与执行方法结合使用时,该操作会起作用。在添加几个动作之前,我开始转换这个动作。
第一次加载 jsp 时,在任何提交之前,我收到错误:
错误 400: Request[/rechercheUtilisateur] 不包含名为隐藏的处理程序参数
这是我的配置:
struts-config:
<action path="/rechercheUtilisateur" type="lan.poujoulat.osac.actions.RechercheUtilisateurAction" name="formRechercheUtilisateur" validate="true" input="/Administration/acces.jsp" scope="request" parameter="hidden">
<forward name="réussiteRecherche" path="/Administration/acces.jsp">
</forward>
jsp Administration/acces.jsp:
<SCRIPT>
function setHidden(value){document.formRechercheUtilisateur.hidden.value=value;}
</SCRIPT>
<html:form action="/rechercheUtilisateur"
name="formRechercheUtilisateur"
type="lan.poujoulat.osac.forms.FormRechercheUtilisateur">
...
<td align="center" width="80"><a href="#"
title='"Rechercher" />'> <input type=image
value=submit src="./image/btnRech.gif" width="22" height="20"
border="0" onclick="setHidden('recherche');"> </a></td>
</a>
...
<html:hidden property="hidden" value="recherche"/>
</html:form>
RechercheUtilisateurAction.java :
public class RechercheUtilisateurAction extends DispatchAction
{
public ActionForward recherche(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
我将隐藏属性添加到我的表单中:
public class FormRechercheUtilisateur extends ValidatorForm
{
...
private String hidden = " ";
...
In order to have multiple actions on one form, I use dispatchAction.
I'm starting with a lonely action which works when I use standard action with execute method. Before adding several action I start to convert this one.
At first load of the jsp, before any submit, I get the error :
Error 400: Request[/rechercheUtilisateur] does not contain handler parameter named hidden
Here is my configuration :
struts-config :
<action path="/rechercheUtilisateur" type="lan.poujoulat.osac.actions.RechercheUtilisateurAction" name="formRechercheUtilisateur" validate="true" input="/Administration/acces.jsp" scope="request" parameter="hidden">
<forward name="réussiteRecherche" path="/Administration/acces.jsp">
</forward>
jsp Administration/acces.jsp :
<SCRIPT>
function setHidden(value){document.formRechercheUtilisateur.hidden.value=value;}
</SCRIPT>
<html:form action="/rechercheUtilisateur"
name="formRechercheUtilisateur"
type="lan.poujoulat.osac.forms.FormRechercheUtilisateur">
...
<td align="center" width="80"><a href="#"
title='"Rechercher" />'> <input type=image
value=submit src="./image/btnRech.gif" width="22" height="20"
border="0" onclick="setHidden('recherche');"> </a></td>
</a>
...
<html:hidden property="hidden" value="recherche"/>
</html:form>
RechercheUtilisateurAction.java :
public class RechercheUtilisateurAction extends DispatchAction
{
public ActionForward recherche(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
I add the hidden property to my form :
public class FormRechercheUtilisateur extends ValidatorForm
{
...
private String hidden = " ";
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您的代码与表单的
hidden
属性冲突。 JavaScript 表单对象 有一个隐藏 对象,表示用于客户端服务器通信的隐藏表单字段。
我不确定以下代码:
是否会设置您使用此设置的隐藏字段的值:
我以前从未使用过此对象,所以我真的不能说。
该消息非常清楚,您没有获得请求中
DispatchAction
所需的参数。这个问题很容易调试,看看服务器的请求到达了哪些参数。您可以将表单方法设置为 GET 以便快速查看,只是为了查看参数是否在 URL 中。首先检查问题出在哪里(服务器端/客户端),然后解决方案可能就像更改字段名称一样简单(“隐藏”名称并不能说明它代表什么)或者您可以这样做类似于:
但我不确定这是否有效。
I think your code is in conflict with the
hidden
property of the form. The JavaScript form object has ahidden
object that represents a hidden form field which is used for client server communications.I am not sure that the following code:
will set the value of the hidden field you've setup with this:
I've never used this object before so I can't really say.
The message is pretty clear, you don't get the parameter that
DispatchAction
needs on the request. The issue is simple to debug, see what parameters arrive on the request at the server. You could set the form method to GET for a quick look, just to see if the parameter is in the URL.First check where the problem is (server side/client side), then the solution might be as simple as changing the name of the field (a name of "hidden" doesn't tell a thing of what it represents) or you could do something like:
but I am not sure if this will work though.
我对索引进行编程以传递我的操作,以便在我的 jsp 之前初始化一些数据。 Index 没有提供隐藏参数。
解决方案:我的 jsp 并不真正需要初始化(空列表不会在我的显示标记中提供问题),因此索引操作转发是 Administration/acces.jsp。不需要执行该操作意味着不需要初始化我的参数。
而jsp中的初始化是通过
this.form.hidden.value = value进行的
I program my index to pass in my action in order to initializee some data before my jsp. Index didn't provide hidden parameter so.
Solution : my jsp do not really need initialization (a null list doesn't provide problem in my display tag) so index action forward is the Administration/acces.jsp. No need to execute the action implies no need to initialize my parameter.
And the initialization in the jsp is made by
this.form.hidden.value = value
您找不到真正的问题,因为真正的问题是这段代码:
我没有提供。 有关
事实上,这与隐藏未初始化
。解决方案:
事实上,在访问我的jsp之前我不需要初始化(我的显示标签中的列表可以为空)
You can't find the real problem because the real problem was this code :
Which I did not provide. Indeed this goes to
with Hidden not initialized.
Solution :
Indeed I did not need initilisation before accessing to my jsp (the list in my display tag can be null)