JSP 后台部分代码不能运行 MVC模式下的开发
我从前台传一个HH:mm格式的时间到这个方法里,代码运行到if(endtime1.getHours()>=begin.getHours()){之后就跳到flag=false那句了,这个判断条件是得到true的,是不是因为我定义的时间格式不相同的原因呢?求高手解答啊!!万分感谢!!
代码如下:
public boolean samedate(Place_user samedate) throws Exception {
// TODO Auto-generated method stub
boolean flag=false;
PreparedStatement psmt=null;
String placebegin=null;
Date begin=null;
SimpleDateFormat time1=new SimpleDateFormat("MM-dd,HH:mm");
SimpleDateFormat time2=new SimpleDateFormat("HH:mm");
//当前时间
String nowtime=time1.format(new Date());
Date nowtime1=time1.parse(nowtime);
//使用结束时间
String endtime=samedate.getEndtime();
Date endtime1=time2.parse(endtime);
String sql="select placebegin from place_date where placeno=?";
try{
psmt=this.conn.prepareStatement(sql);
psmt.setInt(1, samedate.getPlaceno());
ResultSet rs=psmt.executeQuery();
if(rs.next()){
placebegin=(rs.getString(1));
}
begin=time1.parse(placebegin);
//时间段判断
if( nowtime1.getDate()==begin.getDate()){
// if(endtime1.getHours()>=begin.getHours()){
// flag=true;
}else{
flag=false;
}
}
}catch(Exception e){
throw e;
}finally{
try{
psmt.close();
}catch(Exception e){
throw e;
}
}
return flag;
}
代码如下:
public boolean samedate(Place_user samedate) throws Exception {
// TODO Auto-generated method stub
boolean flag=false;
PreparedStatement psmt=null;
String placebegin=null;
Date begin=null;
SimpleDateFormat time1=new SimpleDateFormat("MM-dd,HH:mm");
SimpleDateFormat time2=new SimpleDateFormat("HH:mm");
//当前时间
String nowtime=time1.format(new Date());
Date nowtime1=time1.parse(nowtime);
//使用结束时间
String endtime=samedate.getEndtime();
Date endtime1=time2.parse(endtime);
String sql="select placebegin from place_date where placeno=?";
try{
psmt=this.conn.prepareStatement(sql);
psmt.setInt(1, samedate.getPlaceno());
ResultSet rs=psmt.executeQuery();
if(rs.next()){
placebegin=(rs.getString(1));
}
begin=time1.parse(placebegin);
//时间段判断
if( nowtime1.getDate()==begin.getDate()){
// if(endtime1.getHours()>=begin.getHours()){
// flag=true;
}else{
flag=false;
}
}
}catch(Exception e){
throw e;
}finally{
try{
psmt.close();
}catch(Exception e){
throw e;
}
}
return flag;
}
...全文
相关推荐
用jsp做的MVC模式的用户登录程序的源代码
通过学习这个源代码,开发者可以深入理解如何在实际项目中应用JSP和MVC模式,以及如何实现用户管理和验证等功能。
MVC模式_jsp+javabean+servlet开发“在线考试系统”源代码
**在线考试系统基于MVC模式的开发详解**在软件开发领域,MVC(Model-View-Controller)模式是一种广泛应用于创建Web应用程序的架构模式。
MVC模式jsp网上书店系统
**MVC模式**MVC(Model-View-Controller)模式是一种广泛应用在Web开发中的软件设计模式,它将应用程序分为三个核心部分:模型(Model)、视图(View)和控制器(Controller
jsp中的 mvc模式开发 实例
通过学习这些文件,你可以了解到一个简单的JSP MVC应用是如何组织和运行的。总结,MVC模式在JSP开发中扮演着关键角色,它帮助我们实现清晰的代码结构,提高代码的可读性和可维护性。
jsp基于MVC模式的用户登陆设计
在JSP中使用EL和JSTL来显示模型数据和处理用户输入。综上所述,基于JSP和MVC模式的用户登录设计涉及多个组件的协作,通过合理的分工,可以使代码更加清晰,便于维护和扩展。


Web 开发
