我有index.html中:如何從servlet的動作(請求參數)的index.html
<li><a href="list?action=list">List</a></li>
和servlet類
public class Servlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String action = request.getParameter("action");
if (action.equalsIgnoreCase("List")){
// do something.....
}
}
}
的web.xml
<servlet>
<servlet-name>Servlet</servlet-name>
<servlet-class>ru.proj.top.web.Servlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Servlet</servlet-name>
<url-pattern>/list</url-pattern>
</servlet-mapping>
servlet中的操作爲空。
如何將此參數從index.html
發送到servlet?
請顯示您的'web.xml'。我想對URL映射存在一些誤解。 – JimHawkins