当前位置:编程学习 > JAVA >>

jsp中action怎么写?

我把目录结构写出来,求大神帮我完整的说下,名字不要改变了.

Smarkt-----|
            |---src--|
                        |----com.cn.servlet----|
                        |             |---GoodClassManage.java  
                        |------WEB-ROOT----|
                        |----------|----GoodClassInfo---|
                                      |----GoodClassManage.jsp-----|              
                        |              |----WEB-INF--|
                                                   |---class--| 
                                                               |---com.cn.servlet--|
                                                                             |--GoodClassManage.class
                                      |---web.xml
表单在GoodClassManage.jsp里
<form action=""

怎么弄,麻烦大家每一步写清楚了.感激!^_^^_^
web.xml
 <servlet>
<servlet-name>GoodClassManage</servlet-name>
<servlet-class>com.cn.servlet.GoodClassManage</servlet-class>
  </servlet>
  <servlet-mapping>
<servlet-name>GoodClassManage</servlet-name>
<url-pattern>/GoodClassManage</url-pattern>
  </servlet-mapping>
目前是一直报404错
HTTP Status 404 - /SMarkt/GoodClassInfo/src/GoodClassManage

type Status report

message /SMarkt/GoodClassInfo/src/GoodClassManage

description The requested resource 
(/SMarkt/GoodClassInfo/src/GoodClassManage) is not available
JSP Servlet web.xml --------------------编程问答-------------------- /GoodClassManage
或者../GoodClassManage --------------------编程问答-------------------- 哥,这个真不行,刚又试了

HTTP Status 404 - /GoodClassManage

type Status report

message /GoodClassManage

description The requested resource (/GoodClassManage) is not available.
咋着啊~ --------------------编程问答-------------------- action="GoodClassManage" --------------------编程问答-------------------- classes --------------------编程问答-------------------- 能访问不  http://localhost:8080/Smarkt/GoodClassManage  --------------------编程问答-------------------- 不能访问啊!
改成<%=request.getContextPath()%>/GoodClassManage 和${pageContext.request.contextPath}/GoodClassManage 就能了,但是为什么? --------------------编程问答-------------------- <%=request.getContextPath()%>这是获取服务器根路径的 你可以用火狐看看源代码 就是类似 http://localhost:8080/Smarkt/ --------------------编程问答-------------------- <%=request.getContextPath()%>/跳转的文件名,你试试 <form action="<%=request.getContextPath()%>/InputPositiSer" method="post">不知道是不是你的问题 --------------------编程问答-------------------- 哥,这是你jsp写的有问题啊,一般在head标签中都会写<base href="<%=basePath%>">,你肯定是没有写,谁写action的时候都加上前缀呀,这也太麻烦了吧
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,