<body>
<form action="<% request.getContextPath();%>/login.do" method="post" >
username:<input type="text" name="username"><br>
password:<input type="password" name="password" >
<input type="submit" value="login">
</form>
</body>谁帮我解释一下
<form action="<% request.getContextPath();%>/login.do" method="post" >
这个是什么意思 点提交后 这是指 从JSP页面 跳到哪个类吗 这个request 哪来的
<form action="<% request.getContextPath();%>/login.do" method="post" >
username:<input type="text" name="username"><br>
password:<input type="password" name="password" >
<input type="submit" value="login">
</form>
</body>谁帮我解释一下
<form action="<% request.getContextPath();%>/login.do" method="post" >
这个是什么意思 点提交后 这是指 从JSP页面 跳到哪个类吗 这个request 哪来的
记得好像是这么写吧 <%= request.getContextPath()%><%= request.getContextPath()%>这个东西是为了得到标准的路径 也就是从你的项目开始的根路径。
至于request 他是jsp的内置对象。
那么:"<% request.getContextPath();%>=xxx/service/
也就是你开发项目的路径+servlet 名字,不过我很少在前面加这个 。直接在web.xml配置好了就不要加了 。
这是form表单提交,点击后调到login.do对应的Action 在Action中可以做相应的跳转。
request 是jsp的内置对象。
<% request.getContextPath();%> 是为了表明是工程的根目录开始,一点发布到服务器中时可能路径有改变,这样确保访问路径是从根目录开始的。
request是jsp的内置对象,就是可以直接拿来使用的
request.getContextPath()得到的值是输出项目的路径
使得跟后面的login.do合成一个form的action的地址
<%%>这个写法的作用是向页面输出一段Java代码但是需要注意
此处应该使用的是<%=request.getContextPath()%>
请注意这个等号