1、首页index.jsp,当然可以直接重载:http://localhost:8080/.../index.jsp,没有问题!
2、用户注册成功之后,跳转到index.jsp,附带一个值用户ID
function register() {
$.ajax({
url:"customerAction!getRegisterInfo.action",
type:"POST",
dataType:"json",  
data:{
custName:$("#custName").val(),
custPassword:$("#custPassword").val(),
custEmail:$("#custEmail").val(),
securityCode:$("#securityCode").val(),
},
success:function(msg) {
//成功之后,在这里跳转!!!!
window.location = "index.jsp?custName="+$("#custName").val()+"&custId="+msg.id;
}
}
});
}3、在首页取值:
<% String custId = request.getParameter("custId").trim() ;
String custName = request.getParameter("custName").trim() ; > 没有问题
4、问题是 , 如果这时候 在直接载入 http://localhost:8080/../index.jsp,那么第三步 就会编译出错,因为没有给"custId"和"custName"传值
5、针对window.location 如何跳转到index.jsp的jQuery函数呢

解决方案 »

  1.   

    我大体了解你的意思了,能给页面传值么 ? index.jsp?customName = "22" 这样貌似不可以啊!!
    我觉得可以这样,你用的是struts2 吧, 在每个页面上都会有前分发和后处理两个action处理,所以
    你可以不直接就跳到index.jsp、你可以跳转到你的preIndex.action 把值传给这个action。再用
    request.getParamter();取值。 只是意见。
      

  2.   

    request.getParameter("custId").trim() 
    改为
    (request.getParameter("custId")+"").trim() 
      

  3.   

    那你就在首页做个判断,
    if(request.getParameter("custId")==null){
       String="没有该值";
    }
    其实我也没这样写过,但是思路就是这样了,希望对你有帮助吧!
      

  4.   

    可以不用点trim不,因为你直接加载的时候没传值,null是不能点trim的,所以你不用点trim,或者你像6楼说的做也可以
      

  5.   

    看看你的jQuery数据有没有传送过去,因为json数据是需要{username:'ssss'},有单引号的,不知道你没加会不会识别不到,后台输出下获取的值,如果有的话,就在前台输出下返回的msg,看是不是成功提交完了