最近消息老是遇到一些很简单的但是无法解决的问难
这次遇到的是type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).
在网上搜的方法大都是xml没配置好,url写错,setvlet里doGet()方法没有重载之类的,但是我在servlet里面确实写过doGet方法,可是405错误一直出现
链接是这样写的 <a href= " <%=request.getContextPath()%> /colDemo ">
最早 <a href= "colDemo "> 也不能解决问题(colDemo是一个servlet)
xml配置完好
<servlet>
<servlet-name> colDemo </servlet-name>
<servlet-class> op.colDemo </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> colDemo </servlet-name>
<url-pattern> /colDemo </url-pattern>
</servlet-mapping>
如果大家没有不耐烦,请帮忙看看我写的servlet
package op;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.Servlet;
import java.sql.*;
import java.io.*;
import java.util.*;
import Database.conDB;
public class colDemo extends HttpServlet{
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void doGet(HttpServletResponse response,HttpServletRequest request)
throws IOException,ServletException
{
response.setContentType( "text/html;charset=gb2312 ");
PrintWriter out = response.getWriter();
HttpSession session = request.getSession();
conDB db = new conDB();
String sql = "select * from v_sco_demo ";
ResultSet rs = null;
int rsLen = 0;
ArrayList alDemo = new ArrayList();//以rs.next()存储民主评议分数
ArrayList alID = new ArrayList();//以rs.nect()存储得到该分数的人的ID
try
{
rs = db.Query(sql);
while(rs.next())
{
alDemo.add(rs.getFloat( "sco "));
alID.add(rs.getInt( "beExerID "));
rsLen++;//获取rs长度
}
}
catch(Exception e)
{
e.printStackTrace();
}
String sql1 = " ";
int iUpdt = 0;
conDB db1 = new conDB();
try
{
for(int i = 0;i <rsLen;i++)
{
sql1 = "update total set scoDemo= "+alDemo.get(i)+ "where userID= "+alID.get(i);
iUpdt = db1.Update(sql1);
}
if (iUpdt == 0)
out.println( " <script> alert( '汇总失败 ');history.back(-1); </script> ");
else
{
out.println( " <script> alert( '民主考核汇总成功,点击继续操作! ');window.location.href= 'examTotal.jsp '; </script> ");
}
}