struts中标签的使用

answer512 2007-09-01 12:43:19
<%@ page language="java" contentType="text/html; charset=gb2312"%>
<html>
<head>
<title>修改资料</title>

</head>
<body>
<form action="/update" method="post" name="form" >

请输入用户名:
<input type="text" size="30" />
<p>
请输入密码:
<input type="password" size="30" name="userPwd" />
<p>

<input type="submit" name="submit" value="修改" />
<input type="button" name="button" value="返回" onclick="window.location.href='index.jsp'" />
</form>
</body>
</html>
404错误,提示找不到路径!!!


<%@ page language="java" contentType="text/html; charset=gb2312"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<html>
<head>
<title>修改资料</title>

</head>
<body>
<html:form action="/update" method="post" >

请输入用户名:
<input type="text" size="30" />
<p>
请输入密码:
<input type="password" size="30" name="userPwd" />
<p>

<input type="submit" name="submit" value="修改" />
<input type="button" name="button" value="返回" onclick="window.location.href='index.jsp'" />
</html:form>
</body>
</html>
把form改为html:form就可以运行!!!
为什么会出现这种情况???

...全文
162 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qing2005 2007-09-04
  • 打赏
  • 举报
回复
记住,你在用Struts,就必须用struts规则。
还有,要使用
<html:html>
......
</html:html>

至于<html:form action="/aaa.do" .../>
aaa.do和struts-config中action标签中path对应。
answer512 2007-09-01
  • 打赏
  • 举报
回复
<html:form action="/update" method="post" >中action是action="/manage/update.do";
<form action="/update" method="post" name="form" >中action是action="/update";
一个是绝对路径,一个是相对路径,我把下面的form中的action改为action="/manage/update.do",程序可以运行!
我想问下,struts中想用到form必须用绝对路径吗?
PoemCode 2007-09-01
  • 打赏
  • 举报
回复
请楼主观察<form action="/update" method="post" name="form" >和<html:form action="/update" method="post" > 执行后的页面源码,就是让你在浏览器里执行这个页面,然后查看该页面的源代码,你会发现action="******"是不同的,相信你会明白

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧