window.location.href='teacherInfo.do?method=list&name=${articles.name}'action:request.getparameter("name")
解决方案 »
- LOG4J配置写入数据库的一个疑问,问问大家
- 怎么在博客里写一个button?
- 关于开源项目的学习问题?
- javamail系统找不到指定文件
- hibernate数据不同步
- eclipse项目按右键刷新时总弹出这个错误
- 用过多表DAO的高手门请讲讲你们的用法,小弟我不是太清楚!
- 如何远程发布一个EJB到Weblogic6.1
- JDOM读xml文件出错,请大哥们指教,谢谢,在线等候!谢谢了!
- 我将编译好的项目中的一个class文件反编译后修改了
- hibernate问题:net.sf.hibernate.PropertyAccessException: Exception occurred inside setter of com.Customer.name
- Servlet解密不了encodeURL
错误:
java.lang.NullPointerException应该是没有接收到name属性
onclick="window.location.href=' <html:rewrite page="/teacherInfo.do?method=list'+'&name=${articles.name}'"/>'"
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?
建议用alert弹出<html:rewrite page="/teacherInfo.do?method=list&id=${articles.id}"/>看是什么。。
如是有值就在Action用request.getQuerystring()看有值没。
再没就没办法了。
alert弹出正确的ID 但是ACTION里面得到的不是。
teacherInfo.do?method=list&id=187
再Action里的setId方法手动获取..
看下是什么值。。这也是常用的调试手段。谢谢
onclick="window.location.href=' <html:rewrite page="/teacherInfo.do?method=list&name=${articles.name} "/>'" />
action中用request.getparameter("name")获取你原来的代码中,就压根没有提交name=${articles.name},能获取到数据那才真的是奇迹