window.location.href='teacherInfo.do?method=list&name=${articles.name}'action:request.getparameter("name")

解决方案 »

  1.   

    struts的request是包装了,不能直接引用!
      

  2.   


    错误:
    java.lang.NullPointerException应该是没有接收到name属性
      

  3.   

    1楼的应该能行,这样获取值能获取到了,建议你别用el表达式了,用下struts标签,你的是空指针异常,name没获取到值。articles你这个集合不会没值吧!
      

  4.   

    按照1楼的方法应该可以request.getgetparameter("name")得到值,
    onclick="window.location.href=' <html:rewrite page="/teacherInfo.do?method=list'+'&name=${articles.name}'"/>'"
      

  5.   

    我的ACTION:
                    List list = tis.getTeacherInfos();
    request.getSession().setAttribute("articles", list); String id = (String) request.getParameter("id");
    if (id != null) {
    request.getSession().setAttribute("oneInfo", tis.getTeacherInfo(id)); } else {
    request.getSession().setAttribute("oneInfo", list.get(0));
    } return mapping.findForward("display");display.jsp页面:
    <logic:present name="articles" scope="session">
    <logic:iterate id="articles" collection="${articles}">
    <ul>
    <li>
    <b> ${articles.name} <input type="button"
    class="normalButton" value="aaa"
                    onclick="window.location.href='<html:rewrite page="/teacherInfo.do?method=list&id=${articles.id}"/>'" />
    </b>
    </li>
    </ul>
    </logic:iterate>
    </logic:present>
    </div>
    </div>
    <div class="right">
    <logic:present name="oneInfo" scope="session">
                            ${ oneInfo.name }"
    ${ oneInfo.office }
    ${ oneInfo.position }
    ${ oneInfo.research }
    ${ oneInfo.researchinterests }
    ${ oneInfo.majorwork }
    ${ oneInfo.researchproject }
    </logic:present>
    </div>结果每次都显示list.get(0)的内容   IE浏览器上显示的是正确的ID 如teacherInfo.do?method=list&id=187
    而且点击不同的按钮IE显示的ID都是不一样的,可是为什么ACTION里ID为NULL?
      

  6.   


    建议用alert弹出<html:rewrite page="/teacherInfo.do?method=list&id=${articles.id}"/>看是什么。。
    如是有值就在Action用request.getQuerystring()看有值没。
    再没就没办法了。
      

  7.   


    alert弹出正确的ID 但是ACTION里面得到的不是。
      

  8.   

    难道在Action里面不是同一个request?
      

  9.   

    首先,楼主说的要用action,或者是ssh,或者是其中的一项吧,你就先要去看看这一项当中的一些知识,可能解决你的问题并不困难,但是你首先要弄明白这个知识要怎么来解决你的问题,所以,希望楼主出略的看看struts就够了,真的,就看入门级的,你的问题迎刃而解,真的,这里来发帖,花100分,对某些人真的是奢侈,其实你上网去搜索一下,或者是自己找找,应该不是难题,谢谢
      

  10.   

    先在jsp页面里随便给id付个值.如:
    teacherInfo.do?method=list&id=187 
    再Action里的setId方法手动获取..
    看下是什么值。。这也是常用的调试手段。谢谢
      

  11.   

    window.location.href='teacherInfo.do?method=list&name=${articles.name}' action: request.getparameter("name")
      

  12.   

    楼主,你先print 那个id下 看看什么情况!
      

  13.   

    <input type="button" class="normalButton" value="aaa" 
    onclick="window.location.href=' <html:rewrite page="/teacherInfo.do?method=list&name=${articles.name} "/>'" />
    action中用request.getparameter("name")获取你原来的代码中,就压根没有提交name=${articles.name},能获取到数据那才真的是奇迹
      

  14.   

    用<form>  </form>框起来不就可以了吗?form表单提交,后台action 直接用 request.getparameter()获取
      

  15.   

    lz先弄清楚web应用的 post get  原理。然后你在慢慢解决这个问题。
      

  16.   

    看下Struts相关的书的前面几章你就知道了....帮Action建个FormBean来接受页面提交的参数就行了