rainyday24 发表于 2013-1-29 13:37:13

struts2 jquery json 相关问题

1. ERROR - Could not find action or result 

项目片段描述:ajax登录,需要返回json格式数据判断
 
 struts.xml
 
 
<package name="ajax" extends="json-default" namespace="/ajax"><action name="login" class="com.hspc.jf.web.action.UserAction" method="login"> <result name="success" type="json" > <param name="root">result</param> </result> </action> </package> 
xx.jsp
 
 
<script>jQuery(function($) {//button$("#login").button();$("#reset").button();//dialog$('#dialog_link').click(function(){$('#dialog').dialog({height:180,width:400});return false;});//ajax login$("#login").click(function(){$.ajax({type:"post",url:"ajax/login",data:"user.username="+$("#username").val()+"&user.password="+$("#password").val(),dataType:"json",success: function(result){alert(result);window.location.href="http://localhost:8080/jf/map";}});})});</script> 
反复检查后,依然出现下面问题:No result defined for action com.hspc.jf.web.action.UserAction and result login
 
原因是缺少了jar包,不得不吐槽下,这尼玛的提示。。。几乎没有作用么
 
补充 2012-2-13(2B节,哥们还在写代码http://www.agoit.com/images/smiles/icon_cry.gif)
提出一点当缺少 struts2-json-plugin  的时候,会提示
 
ERROR - Unable to find parent packages json-default
 
以下是maven中依赖
 
<dependency><groupId>net.sf.json-lib</groupId><artifactId>json-lib</artifactId><version>2.4</version><type>jar</type><classifier>jdk15</classifier><scope>compile</scope></dependency><dependency><groupId>org.apache.struts</groupId><artifactId>struts2-json-plugin</artifactId><version>2.1.8.1</version><type>jar</type><scope>compile</scope></dependency>  还有一点,我很好奇maven依赖中有冲突conflicted会肿么样
 
http://pic.yupoo.com/rainyday24/BJYX9V2s/medish.jpg
页: [1]
查看完整版本: struts2 jquery json 相关问题