javaweb的兼职网页项目,连接数据库时404,请大佬指点

无法向数据库内添加数据,直接404
在这里插入图片描述
点击发布后
在这里插入图片描述

下面是详细的
任务发布页面html:

#head {
height: 120px;
width: 100;
background-color: #66CCCC;
text-align: center;
position: relative;
}
#foot {
width: 100;
height: 126px;
background-color: #CC9933;
position: relative;
}

.title {
font-family: “宋体”;
color: #FFFFFF;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%); /* 使用css3的transform来实现 */
font-size: 36px;
height: 40px;
width: 30%;
}

.copyright {
font-family: “宋体”;
color: #FFFFFF;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%); /* 使用css3的transform来实现 */
height: 60px;
width: 40%;
text-align:center;
}

#foot .copyright .img {
width: 100%;
height: 24px;
position: relative;
}
.copyright .img .icon {
display: inline-block;
width: 24px;
height: 24px;
margin-left: 22px;
vertical-align: middle;
background-image: url(%E7%94%B5%E5%AD%90%E9%82%AE%E4%BB%B6.png);
background-repeat: no-repeat;
vertical-align: middle;
margin-right: 5px;
}

.copyright .img .icon1 {
display: inline-block;
width: 24px;
height: 24px;
margin-left: 22px;
vertical-align: middle;
background-image: url(%E5%9C%B0%E5%9D%80.png);
background-repeat: no-repeat;
vertical-align: middle;
margin-right: 5px;
}
.copyright .img .icon2 {
display: inline-block;
width: 24px;
height: 24px;
margin-left: 22px;
vertical-align: middle;
background-image: url(%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F.png);
background-repeat: no-repeat;
vertical-align: middle;
margin-right: 5px;
}
#foot .copyright p {
height: 24px;
width: 100%;
}

  .main input,select{
     width: 250px;
     padding: 4px;
     margin: 2px;
  }








兼职名称:


兼职类型: 服务类 销售类 研究类 艺术类 教育类 生产类 运输类 体育类 其他



兼职地点:


兼职工资/元每小时:

10元以下 10~20 20~30 30~50 50元以上


具体兼职时间:

兼职内容:

兼职规则:

兼职范围: 学校周边 5km左右 较远



兼职时长: 一周内 一周到两周 两周到一月 一个月到两个月 两个月到三个月 三个月到半年 半年以上

每日兼职时长: 0~2小时 2~4小时 4~6小时 6小时以上

发布人:




     <div class="footer" id="foot">
联系地址:火星
联系电话:999

Addjobjava页面:
package addController;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import addDao.job;
import addDao.jobInterface;
import addDao.addJob;

@WebServlet("/AddJob")
public class AddJob extends HttpServlet {
private static final long serialVersionUID = 1L;

public AddJob() {
super();
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String ajob=request.getParameter(“job”);
String type=request.getParameter(“type”);
String place=request.getParameter(“place”);
String money=request.getParameter(“money”);
String date=request.getParameter(“date”);
String dowhat=request.getParameter(“dowhat”);
String rule=request.getParameter(“rule”);
String fanwei=request.getParameter(“fanwei”);
String jobtime=request.getParameter(“jobtime”);
String daytime=request.getParameter(“daytime”);
String name=request.getParameter(“name”);
jobInterface qq=new addJob();
PrintWriter out=response.getWriter();
job u=new job(ajob,type,place,money,date,dowhat,rule,fanwei,jobtime,daytime,name);
qq.insertJob(u);
out.println(“ok”);
response.sendRedirect(“showjob.jsp”);

  }

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding(“UTF-8”);
response.setContentType(“text/html;charset=UTF-8”);
doGet(request, response);
}

}

addjob页面:
package addDao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import addDao.DbUtils;

public class addJob implements jobInterface {

@Override
public void insertJob(job a) {
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
try {
conn=DbUtils.getConnection();
String sql=“insert into dagongzai.partjob (job” //兼职名称
+ “,type”
+ “,place”
+ “,money”
+ “,date”
+ “,dowhat”
+ “,rule”
+ “,fanwei”
+ “,jobtime”
+ “,daytime,”
+ “name)”
+ “values(?,?,?,?,?,?,?,?,?,?,?)”;
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, a.getJob());
pstmt.setString(2, a.getType() );
pstmt.setString(3, a.getPlace());
pstmt.setString(4, a.getMoney());
pstmt.setString(5, a.getDate());
pstmt.setString(6, a.getDowhat());
pstmt.setString(7, a.getRule());
pstmt.setString(8, a.getFanwei());
pstmt.setString(9, a.getJobtime());
pstmt.setString(10, a.getDaytime());
pstmt.setString(11, a.getName());
pstmt.executeUpdate();//插入到数据库
} catch (SQLException e) {
e.printStackTrace();
}finally
{
DbUtils.closeResultSet(rs);
DbUtils.closeStatement(pstmt);
DbUtils.closeConnection(conn);
}
}

@Override
public void deleteJob(int dno) {
// TODO Auto-generated method stub

}

@Override
public void updateJob(job c) {
// TODO Auto-generated method stub

}

@Override
public void queryJob(job d) {
// TODO Auto-generated method stub

}

@Override
public List getAllJob() {
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
List jobs=new ArrayList<>();
try {

     //2.连接数据库      
     conn=DbUtils.getConnection();
     //System.out.println("ok");

//3. 操作数据库
String sql=“select * from dagongzai.partjob”;
System.out.println(conn);
pstmt=conn.prepareStatement(sql);
//System.out.println(conn);

  rs=pstmt.executeQuery();
  while(rs.next())
  {

job u=new job();
u.setJob(rs.getString(“job”));
u.setType(rs.getString(“type”));
u.setPlace(rs.getString(“place”));
u.setMoney(rs.getString(“money”));
u.setDate(rs.getString(“date”));
u.setDowhat(rs.getString(“dowhat”));
u.setRule(rs.getString(“rule”));
u.setFanwei(rs.getString(“fanwei”));
u.setJobtime(rs.getString(“jobtime”));
u.setDaytime(rs.getString(“daytime”));
u.setName(rs.getString(“name”));
jobs.add(u);
}

  } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
  }finally{

//4.关闭数据库
DbUtils.closeResultSet(rs);
DbUtils.closeStatement(pstmt);
DbUtils.closeConnection(conn);
}
System.out.println(jobs.size());

  return jobs;

}

@Override
public job getJobByDno(int apartno) {
// TODO Auto-generated method stub
return null;
}

}
Dbutils页面:
package addDao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DbUtils {
private static final String URL=“jdbc:mysql://localhost:3306/dagongzai?useUnicode=true&characterEncoding=utf8”;//&useSSL=false
private static final String USERNAME=“root”;
private static final String PASSWORD=“12345678”;

private DbUtils(){}

static{
try {
Class.forName(“com.mysql.jdbc.Driver”);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public static Connection getConnection()
{
Connection conn=null;
try {
conn=DriverManager.getConnection(URL, USERNAME, PASSWORD);
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}

public static void closeConnection(Connection conn)
{
try {
if(conn!=null)
{
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}

public static void closeResultSet(ResultSet rs)
{
try {
if(rs!=null)
{
rs.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void closeStatement(Statement stmt)
{
try {
if(stmt!=null)
{
stmt.close();
}
}

catch (SQLException e) {
e.printStackTrace();
}
}

}

job页面:
package addDao;

public class job {
private int id;
private String job;
private String type;
private String place;
private String money;
private String date;
private String dowhat;
private String rule;
private String fanwei;
private String jobtime;
private String daytime;
private String name;
public job() {}
public job(String a,String b,String c,String d,String e,String f,String g,String h,String i,String j,String k)
{
this.job=a;
this.type=b;
this.place=c;
this.money=d;
this.date=e;
this.dowhat=f;
this.rule=g;
this.fanwei=h;
this.jobtime=i;
this.daytime=j;
this.name=k;
}

public String getMoney() {
return money;
}
public void setMoney(String money) {
this.money = money;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getFanwei() {
return fanwei;
}
public void setFanwei(String fanwei) {
this.fanwei = fanwei;
}
public String getJobtime() {
return jobtime;
}
public void setJobtime(String jobtime) {
this.jobtime = jobtime;
}
public String getDaytime() {
return daytime;
}
public void setDaytime(String daytime) {
this.daytime = daytime;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getPlace() {
return place;
}
public void setPlace(String place) {
this.place = place;
}

public String getDowhat() {
return dowhat;
}
public void setDowhat(String dowhat) {
this.dowhat = dowhat;
}
public String getRule() {
return rule;
}
public void setRule(String rule) {
this.rule = rule;
}

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

}

jobinterface页面:

package addDao;
import java.util.List;

public interface jobInterface {
void insertJob(job u);
void deleteJob(int dno);
void updateJob(job c);
void queryJob(job d);
List getAllJob();
job getJobByDno(int apartno);
}

以上有有关的页面,请各位大佬指点一下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值