Struts2.0 表单中用到select标签提交时出错
2008-11-13 21:44
405 查看
在表单用中到了select标签,页面初始化时一切正常,select也正常初始化
可是当我提交时就出现如下错误:
严重: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'functions.typeId': The requested list key '%{types}' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
在应用中我用到两个Action,两个jsp页面
一个FunctionsAction,一个FunctionstypeAction
一个add_function.jsp,一个add_functions_success.jsp
具休流程是我从FunctionstypeAction中获取一个functionstypes的List
用来初始化add_function.jsp中的select标签,
然后把表单提交给FunctionsAction中的insert方法
add_function.jsp初始化是正常的,
但是点提交到FunctionsAction的时候页面空白
我看了一下源文件,页面只执行了一部分,
代码如下:
Java代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body style="text-align:center;">
<form id="insertFunction" onsubmit="return true;" action="insertFunction.action" method="post">
<table class="wwFormTable">
下面列出Action,xml配置和jsp页面的代码
FunctionsAction:
Java代码
package com.mp.job.baseinfo.action;
import java.util.List;
import com.mp.job.baseinfo.service.IFunctionsService;
import com.mp.job.baseinfo.vo.Functions;
import com.mp.job.common.service.JobActionSupport;
import com.mp.job.exception.BaseException;
import com.mp.job.util.Pager;
@SuppressWarnings("serial")
public class FunctionsAction extends JobActionSupport {
private IFunctionsService functionsService;
private Functions functions;
private List functionsRecords;
@SuppressWarnings("unused")
private Object[][] params;
private Pager pager;
<!-- getter和setter这里省略! -->
public String insert()throws BaseException{
try{
functionsService.save(functions);
}catch(Exception e){
e.toString();
addActionMessage("插入数据时出现异常!");
return INPUT;
}
return SUCCESS;
}
<!-- 其他的方法省略 -->
}
FunctionstypeAction:
Java代码
package com.mp.job.baseinfo.action;
import java.util.List;
import com.mp.job.baseinfo.service.IFunctionstypeService;
import com.mp.job.baseinfo.vo.Functionstype;
import com.mp.job.common.service.JobActionSupport;
import com.mp.job.exception.BaseException;
import com.mp.job.util.Pager;
@SuppressWarnings("serial")
public class FunctionstypeAction extends JobActionSupport {
private IFunctionstypeService functionstypeService;
private Functionstype functionstype;
private List functionstypes;
private List functionstypeRecords;
@SuppressWarnings("unused")
private Object[][] params;
private Pager pager;
<!-- getter和setter这里省略! -->
@SuppressWarnings("unchecked")
public String getAllFunctionstypes()throws BaseException{
functionstypes = functionstypeService.findAll();
return null;
}
<!-- 其他方法这里省略! -->
public List getFunctionstypes() {
return functionstypes;
}
public void setFunctionstypes(List functionstypes) {
this.functionstypes = functionstypes;
}
}
struts.xml --->>>其中用到的Action我都在Spring中配置过了
Java代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- ================================================================== -->
<!-- 名称相关functionsAction -->
<!-- ================================================================== -->
<package name="functions" namespace="/admin/BaseInfo"
extends="struts-default">
<action name="insertFunction" class="functionsAction"
method="insert">
<result name="success">search_Functions.jsp</result>
<result name="input">add_function.jsp</result>
</action>
<!-- 其他配置省略 -->
</package>
<!-- ================================================================== -->
<!-- 类型相关Action -->
<!-- ================================================================== -->
<package name="functionstype" namespace="/admin/BaseInfo"
extends="struts-default">
<action name="getAllFunctionstypes" class="functionstypeAction"
method="getAllFunctionstypes">
</action>
<!-- 其他配置省略 -->
</package>
</struts>
add_function.jsp: --->>>就这个页面害我两天没睡好觉
Java代码
<%@page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body style="text-align:center;">
<s:actionmessage />
<s:action name="getAllFunctionstypes" id="getAllFunctionstypes" />
<s:set name="types" value="#getAllFunctionstypes.functionstypes"/>
<s:form action="insertFunction.action" method="post">
<s:select list="%{types}"
listKey="id"
listValue="name"
name="functions.typeId"
label="类型"/>
<s:textfield name="functions.name" label="名称"/>
<s:submit value="添加"/>
</s:form>
<hr/>
</body>
</html>
add_function_success.jsp: --->>>这个页面很简单,个人认为错误不会出在这里,呵呵
Java代码
<%@page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body style="text-align:center;">
<table width="350px" height="150px" align="center" bgcolor="#ffff00">
<tr><td style="color:#00ff00;"><b>成功添加数据!</b><br/><br/>
<a href="add_function.jsp">继续添加</a> <a href="listAllFunctions.action">查看全部</a>
</td></tr>
</table>
</body>
</html>
我现在的感觉是List是不是只能从同一个Action中调出,也只能提交到同一个Action????
23:47
浏览 (4435)
论坛浏览 (4133)
评论 (8)
分类: Struts2.0
收藏
相关推荐
评论
xinlcao 2007-08-26 回复
这个错误应该是由于提交的时候,校验出错,返回到提交页面,然后这个时候是直接返回到jsp页面,action没有执行,造成取list的时候没有值,当然不用校验就不会出错了,看看你的校验代码,或者修改action类就行了。
引用
FunctionstypeAction:
代码
package com.mp.job.baseinfo.action; import java.util.List; import com.mp.job.baseinfo.service.IFunctionstypeService; import com.mp.job.baseinfo.vo.Functionstype; import com.mp.job.common.service.JobActionSupport; import com.mp.job.exception.BaseException; import com.mp.job.util.Pager; @SuppressWarnings("serial") public class FunctionstypeAction extends JobActionSupport { private IFunctionstypeService functionstypeService; private Functionstype functionstype; private List functionstypes; private List functionstypeRecords; @SuppressWarnings("unused") private Object[][] params; private Pager pager; <!-- getter和setter这里省略! --> @SuppressWarnings("unchecked") public String getAllFunctionstypes()throws BaseException{ functionstypes = functionstypeService.findAll(); return null; } <!-- 其他方法这里省略! --> public List getFunctionstypes() { return functionstypes; } public void setFunctionstypes(List functionstypes) { this.functionstypes = functionstypes; } }
修改成:
Java代码
//public String getAllFunctionstypes()throws BaseException{
// functionstypes = functionstypeService.findAll();
// return null;
//}
<!-- 其他方法这里省略! -->
public List getFunctionstypes() {
return functionstypeService.findAll();
}
//public void setFunctionstypes(List functionstypes) {
// this.functionstypes = functionstypes;
//}
linyuelei 2007-06-26 回复
<action name="getAllFunctionstypes" class="functionstypeAction"method="getAllFunctionstypes">
<interceptor-ref name="basicStack"/>
</action>
linyuelei 2007-06-26 回复
妈的,终于搞定了加上拦截器<interceptor-ref name="basicStack"/>就可以了出来。
linyuelei 2007-06-26 回复
我页碰到了这个问题,好几天了都没解决!
能具体的说下验证文件那出问题了?我的邮件linyl@pominfo.cn
期待回复。谢谢!
soardragon 2007-06-24 回复
谢谢你的建议
问题已经解决,就是验证文件的问题,
让我恼的差点砸电脑,
不过问题过去了,感觉select还是满有用的,呵呵...
yidishui 2007-06-24 回复
我觉得很有可能是
Java代码
<s:action name="getAllFunctionstypes" id="getAllFunctionstypes" />
我在webwork中刚开始也遇到同样的问题
soardragon 2007-06-23 回复
movingboy 多谢你的回答!
今天把action包中的一个验证配置给删了,结果就正常了,
顺便问一个
如果Action的验证配置没有起别名的话是不是会过滤掉所有的东西?
我删的那个配置文件是xxxAction-validation.xml
如果我要针对insert方法过滤是不是要这样写
xxxAction-insert-validation.xml?
movingboy 2007-06-23 回复
在JSP中不使用<s:set>标签,直接按下面写试试:
Java代码
<%@page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body style="text-align:center;">
<s:actionmessage />
<s:action name="getAllFunctionstypes" id="getAllFunctionstypes" />
<s:form action="insertFunction.action" method="post">
<s:select list="#getAllFunctionstypes.functionstypes"
listKey="id"
listValue="name"
name="functions.typeId"
label="职能类型"/>
<s:textfield name="functions.name" label="职能名称"/>
<s:submit value="添加"/>
</s:form>
<hr/>
</body>
</html>
另外说一句:list是可以从其它action中取的,
可是当我提交时就出现如下错误:
严重: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'functions.typeId': The requested list key '%{types}' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
在应用中我用到两个Action,两个jsp页面
一个FunctionsAction,一个FunctionstypeAction
一个add_function.jsp,一个add_functions_success.jsp
具休流程是我从FunctionstypeAction中获取一个functionstypes的List
用来初始化add_function.jsp中的select标签,
然后把表单提交给FunctionsAction中的insert方法
add_function.jsp初始化是正常的,
但是点提交到FunctionsAction的时候页面空白
我看了一下源文件,页面只执行了一部分,
代码如下:
Java代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body style="text-align:center;">
<form id="insertFunction" onsubmit="return true;" action="insertFunction.action" method="post">
<table class="wwFormTable">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>首页</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> </head> <body style="text-align:center;"> <form id="insertFunction" onsubmit="return true;" action="insertFunction.action" method="post"> <table class="wwFormTable">
下面列出Action,xml配置和jsp页面的代码
FunctionsAction:
Java代码
package com.mp.job.baseinfo.action;
import java.util.List;
import com.mp.job.baseinfo.service.IFunctionsService;
import com.mp.job.baseinfo.vo.Functions;
import com.mp.job.common.service.JobActionSupport;
import com.mp.job.exception.BaseException;
import com.mp.job.util.Pager;
@SuppressWarnings("serial")
public class FunctionsAction extends JobActionSupport {
private IFunctionsService functionsService;
private Functions functions;
private List functionsRecords;
@SuppressWarnings("unused")
private Object[][] params;
private Pager pager;
<!-- getter和setter这里省略! -->
public String insert()throws BaseException{
try{
functionsService.save(functions);
}catch(Exception e){
e.toString();
addActionMessage("插入数据时出现异常!");
return INPUT;
}
return SUCCESS;
}
<!-- 其他的方法省略 -->
}
package com.mp.job.baseinfo.action; import java.util.List; import com.mp.job.baseinfo.service.IFunctionsService; import com.mp.job.baseinfo.vo.Functions; import com.mp.job.common.service.JobActionSupport; import com.mp.job.exception.BaseException; import com.mp.job.util.Pager; @SuppressWarnings("serial") public class FunctionsAction extends JobActionSupport { private IFunctionsService functionsService; private Functions functions; private List functionsRecords; @SuppressWarnings("unused") private Object[][] params; private Pager pager; <!-- getter和setter这里省略! --> public String insert()throws BaseException{ try{ functionsService.save(functions); }catch(Exception e){ e.toString(); addActionMessage("插入数据时出现异常!"); return INPUT; } return SUCCESS; } <!-- 其他的方法省略 --> }
FunctionstypeAction:
Java代码
package com.mp.job.baseinfo.action;
import java.util.List;
import com.mp.job.baseinfo.service.IFunctionstypeService;
import com.mp.job.baseinfo.vo.Functionstype;
import com.mp.job.common.service.JobActionSupport;
import com.mp.job.exception.BaseException;
import com.mp.job.util.Pager;
@SuppressWarnings("serial")
public class FunctionstypeAction extends JobActionSupport {
private IFunctionstypeService functionstypeService;
private Functionstype functionstype;
private List functionstypes;
private List functionstypeRecords;
@SuppressWarnings("unused")
private Object[][] params;
private Pager pager;
<!-- getter和setter这里省略! -->
@SuppressWarnings("unchecked")
public String getAllFunctionstypes()throws BaseException{
functionstypes = functionstypeService.findAll();
return null;
}
<!-- 其他方法这里省略! -->
public List getFunctionstypes() {
return functionstypes;
}
public void setFunctionstypes(List functionstypes) {
this.functionstypes = functionstypes;
}
}
package com.mp.job.baseinfo.action; import java.util.List; import com.mp.job.baseinfo.service.IFunctionstypeService; import com.mp.job.baseinfo.vo.Functionstype; import com.mp.job.common.service.JobActionSupport; import com.mp.job.exception.BaseException; import com.mp.job.util.Pager; @SuppressWarnings("serial") public class FunctionstypeAction extends JobActionSupport { private IFunctionstypeService functionstypeService; private Functionstype functionstype; private List functionstypes; private List functionstypeRecords; @SuppressWarnings("unused") private Object[][] params; private Pager pager; <!-- getter和setter这里省略! --> @SuppressWarnings("unchecked") public String getAllFunctionstypes()throws BaseException{ functionstypes = functionstypeService.findAll(); return null; } <!-- 其他方法这里省略! --> public List getFunctionstypes() { return functionstypes; } public void setFunctionstypes(List functionstypes) { this.functionstypes = functionstypes; } }
struts.xml --->>>其中用到的Action我都在Spring中配置过了
Java代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- ================================================================== -->
<!-- 名称相关functionsAction -->
<!-- ================================================================== -->
<package name="functions" namespace="/admin/BaseInfo"
extends="struts-default">
<action name="insertFunction" class="functionsAction"
method="insert">
<result name="success">search_Functions.jsp</result>
<result name="input">add_function.jsp</result>
</action>
<!-- 其他配置省略 -->
</package>
<!-- ================================================================== -->
<!-- 类型相关Action -->
<!-- ================================================================== -->
<package name="functionstype" namespace="/admin/BaseInfo"
extends="struts-default">
<action name="getAllFunctionstypes" class="functionstypeAction"
method="getAllFunctionstypes">
</action>
<!-- 其他配置省略 -->
</package>
</struts>
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <!-- ================================================================== --> <!-- 名称相关functionsAction --> <!-- ================================================================== --> <package name="functions" namespace="/admin/BaseInfo" extends="struts-default"> <action name="insertFunction" class="functionsAction" method="insert"> <result name="success">search_Functions.jsp</result> <result name="input">add_function.jsp</result> </action> <!-- 其他配置省略 --> </package> <!-- ================================================================== --> <!-- 类型相关Action --> <!-- ================================================================== --> <package name="functionstype" namespace="/admin/BaseInfo" extends="struts-default"> <action name="getAllFunctionstypes" class="functionstypeAction" method="getAllFunctionstypes"> </action> <!-- 其他配置省略 --> </package> </struts>
add_function.jsp: --->>>就这个页面害我两天没睡好觉
Java代码
<%@page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body style="text-align:center;">
<s:actionmessage />
<s:action name="getAllFunctionstypes" id="getAllFunctionstypes" />
<s:set name="types" value="#getAllFunctionstypes.functionstypes"/>
<s:form action="insertFunction.action" method="post">
<s:select list="%{types}"
listKey="id"
listValue="name"
name="functions.typeId"
label="类型"/>
<s:textfield name="functions.name" label="名称"/>
<s:submit value="添加"/>
</s:form>
<hr/>
</body>
</html>
<%@page language="java" pageEncoding="utf-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>首页</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> </head> <body style="text-align:center;"> <s:actionmessage /> <s:action name="getAllFunctionstypes" id="getAllFunctionstypes" /> <s:set name="types" value="#getAllFunctionstypes.functionstypes"/> <s:form action="insertFunction.action" method="post"> <s:select list="%{types}" listKey="id" listValue="name" name="functions.typeId" label="类型"/> <s:textfield name="functions.name" label="名称"/> <s:submit value="添加"/> </s:form> <hr/> </body> </html>
add_function_success.jsp: --->>>这个页面很简单,个人认为错误不会出在这里,呵呵
Java代码
<%@page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body style="text-align:center;">
<table width="350px" height="150px" align="center" bgcolor="#ffff00">
<tr><td style="color:#00ff00;"><b>成功添加数据!</b><br/><br/>
<a href="add_function.jsp">继续添加</a> <a href="listAllFunctions.action">查看全部</a>
</td></tr>
</table>
</body>
</html>
<%@page language="java" pageEncoding="utf-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>首页</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> </head> <body style="text-align:center;"> <table width="350px" height="150px" align="center" bgcolor="#ffff00"> <tr><td style="color:#00ff00;"><b>成功添加数据!</b><br/><br/> <a href="add_function.jsp">继续添加</a> <a href="listAllFunctions.action">查看全部</a> </td></tr> </table> </body> </html>
我现在的感觉是List是不是只能从同一个Action中调出,也只能提交到同一个Action????
23:47
浏览 (4435)
论坛浏览 (4133)
评论 (8)
分类: Struts2.0
收藏
相关推荐
评论
xinlcao 2007-08-26 回复
这个错误应该是由于提交的时候,校验出错,返回到提交页面,然后这个时候是直接返回到jsp页面,action没有执行,造成取list的时候没有值,当然不用校验就不会出错了,看看你的校验代码,或者修改action类就行了。
引用
FunctionstypeAction:
代码
package com.mp.job.baseinfo.action; import java.util.List; import com.mp.job.baseinfo.service.IFunctionstypeService; import com.mp.job.baseinfo.vo.Functionstype; import com.mp.job.common.service.JobActionSupport; import com.mp.job.exception.BaseException; import com.mp.job.util.Pager; @SuppressWarnings("serial") public class FunctionstypeAction extends JobActionSupport { private IFunctionstypeService functionstypeService; private Functionstype functionstype; private List functionstypes; private List functionstypeRecords; @SuppressWarnings("unused") private Object[][] params; private Pager pager; <!-- getter和setter这里省略! --> @SuppressWarnings("unchecked") public String getAllFunctionstypes()throws BaseException{ functionstypes = functionstypeService.findAll(); return null; } <!-- 其他方法这里省略! --> public List getFunctionstypes() { return functionstypes; } public void setFunctionstypes(List functionstypes) { this.functionstypes = functionstypes; } }
修改成:
Java代码
//public String getAllFunctionstypes()throws BaseException{
// functionstypes = functionstypeService.findAll();
// return null;
//}
<!-- 其他方法这里省略! -->
public List getFunctionstypes() {
return functionstypeService.findAll();
}
//public void setFunctionstypes(List functionstypes) {
// this.functionstypes = functionstypes;
//}
//public String getAllFunctionstypes()throws BaseException{ // functionstypes = functionstypeService.findAll(); // return null; //} <!-- 其他方法这里省略! --> public List getFunctionstypes() { return functionstypeService.findAll(); } //public void setFunctionstypes(List functionstypes) { // this.functionstypes = functionstypes; //}
linyuelei 2007-06-26 回复
<action name="getAllFunctionstypes" class="functionstypeAction"method="getAllFunctionstypes">
<interceptor-ref name="basicStack"/>
</action>
linyuelei 2007-06-26 回复
妈的,终于搞定了加上拦截器<interceptor-ref name="basicStack"/>就可以了出来。
linyuelei 2007-06-26 回复
我页碰到了这个问题,好几天了都没解决!
能具体的说下验证文件那出问题了?我的邮件linyl@pominfo.cn
期待回复。谢谢!
soardragon 2007-06-24 回复
谢谢你的建议
问题已经解决,就是验证文件的问题,
让我恼的差点砸电脑,
不过问题过去了,感觉select还是满有用的,呵呵...
yidishui 2007-06-24 回复
我觉得很有可能是
Java代码
<s:action name="getAllFunctionstypes" id="getAllFunctionstypes" />
<s:action name="getAllFunctionstypes" id="getAllFunctionstypes" />里面加了不合适的拦截器,特别象验证的拦截器,这样你在form提交的时候 却没有验证成功造成的
我在webwork中刚开始也遇到同样的问题
soardragon 2007-06-23 回复
movingboy 多谢你的回答!
今天把action包中的一个验证配置给删了,结果就正常了,
顺便问一个
如果Action的验证配置没有起别名的话是不是会过滤掉所有的东西?
我删的那个配置文件是xxxAction-validation.xml
如果我要针对insert方法过滤是不是要这样写
xxxAction-insert-validation.xml?
movingboy 2007-06-23 回复
在JSP中不使用<s:set>标签,直接按下面写试试:
Java代码
<%@page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body style="text-align:center;">
<s:actionmessage />
<s:action name="getAllFunctionstypes" id="getAllFunctionstypes" />
<s:form action="insertFunction.action" method="post">
<s:select list="#getAllFunctionstypes.functionstypes"
listKey="id"
listValue="name"
name="functions.typeId"
label="职能类型"/>
<s:textfield name="functions.name" label="职能名称"/>
<s:submit value="添加"/>
</s:form>
<hr/>
</body>
</html>
<%@page language="java" pageEncoding="utf-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>首页</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> </head> <body style="text-align:center;"> <s:actionmessage /> <s:action name="getAllFunctionstypes" id="getAllFunctionstypes" /> <s:form action="insertFunction.action" method="post"> <s:select list="#getAllFunctionstypes.functionstypes" listKey="id" listValue="name" name="functions.typeId" label="职能类型"/> <s:textfield name="functions.name" label="职能名称"/> <s:submit value="添加"/> </s:form> <hr/> </body> </html>
另外说一句:list是可以从其它action中取的,
相关文章推荐
- struts2 防止表单重复提交主要用的到标签是<s: token />
- [Struts2.0学习笔记]select标签
- 《struts---利用struts的标签,实现简单的表单提交及校验》
- struts2.0经典标签---级联select--
- Struts2.0表单标签
- Struts表单无法提交/循环标签无法读取——禁忌单词province
- struts2.0 select标签 如何设置下拉框默认值
- 在表单提交中用到的html5新标签
- truts2中表单可以不用struts自带的<s:form>标签,直接用html的<form>标签能够提交数据到action
- struts2 使用标签防止表单重复提交
- 提交表单时,固定jsp页面<select>标签下option的值不刷新
- struts_05 各种验证器,ognl表达式,struts2常用标签,防止表单重复提交,jfreeChart插件的运用
- JAVAWEB开发之Struts2详解(四)——ognl与valueStack(重点)、Struts常用标签、防止表单重复提交、Struts2中内置json插件
- <input type="image">标签引发的form表单自动提交
- 提交表单存在html标签报错-检测到有潜在危险的 Request.Form 值
- 提交form表单时未获取到select下拉框的value
- spring mvc中使用spring form标签无法正常提交表单
- struts 跨表单提交,分步注册
- a标签点击跳转或表单提交前弹出确认框
- struts form表单提交action处理之后没有跳转页面