我在spring web应用程序中有以下控制器:
@Controller
public class MigrationController {
/* @Autowired
com.nated.app.migration.service.AddItemService Service;*/
@RequestMapping("/signin")
public ModelAndView signIn() {
ModelAndView mav = new ModelAndView("signin");
//MigrationTO bean = new MigrationTO();
//mav.addObject("searchUserGet", bean);
return mav;
}
@RequestMapping("/migration")
public ModelAndView searchContact() {
//MigrationTO bean = new MigrationTO();
//mav.addObject("searchUserGet", bean);
MigrationService migrationService=new MigrationService();
MigrationTO migrationTO=migrationService.getMigrationItems("OTH");
ModelAndView mav = new ModelAndView("migrationPage");
mav.addObject("migrationTO", migrationTO);
return mav;
}
}
查看方法searchcontact
,方法getmigrationItem
未被调用。
任何人都建议我一些解决方案
import java.util.List;
import com.nated.app.migration.beans.MigrationTO;
import com.nated.app.migration.dao.IMigrationDao;
import com.nated.app.migration.dao.impl.MigrationDaoImpl;
public class MigrationService {
public MigrationTO getMigrationItems(String status){
List<MigrationTO> lst = null;
MigrationTO migrationTO=null;
try {
IMigrationDao migrationDao=new MigrationDaoImpl();
migrationTO = migrationDao.getMigrationItems(status);
if(migrationTO.getOthersFlag()=="Y"){
migrationTO = migrationDao.getMigrationItemsOther("Nap");
}
return migrationTO;
} catch (Exception exception) {
//logger.log(Level.SEVERE, exception.getMessage());
exception.printStackTrace();
//throw exception;
} finally {
//logger.log(Level.INFO, "getMigrationItems Ends");
}
}
}
这是服务,它是否有效,我在最后一行(返回)放置了断点。