Insert picture description here

ssm framework integration (simple addition, deletion, modification and query)

class=”markdown_views prism-atom-one-dark”> 1. Environmental requirements myEclipse+jdk1.8+tomcat7+ssm framework requires jar https://pan.baidu.com/s/1eNn658Hkncm4z28yQtEqxg Extraction code: 18fd Second, project structure screenshot: Third, detailed configuration of the configuration file: 1. web. xml configuration file: springMVC org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:applicationContext.xml 1 springMVC / charcterEncoding org.springframework.web.filter.CharacterEncodingFilter encoding utf-8 charcterEncoding /* org.springframework.web.context.ContextLoaderListener contextConfigLocation classpath:applicationContext.xml 2. mybatis.xml file: 3, applicationContext.xml file configuration q_lastModify=#{q_lastModify}, where q_id = #{q_id} 6. Service layer and its implementation class: Answer //AnswerService.java public interface AnswerService { // To answer the question, just add answer int addAnswer(Answer answer); // Query the answer below the question List selAllAnswer(@Param(“q_Id”) int q_Id); // query the last record Answer selAnswerByLastId(); } //AnswerServiceImpl.java @Service(“answerServiceImpl”) public class AnswerServiceImpl implements AnswerService{ @Resource private AnswerMapper answerMapper; @Resource private QuestionMapper questionMapper; /** * To answer a question, just add an answer * @param answer * @return */ @Override public int addAnswer(Answer answer) { answer.setA_date(MyUtil.getDate()); int addAnswerIndex = answerMapper. addAnswer(answer); Question selQuestionById = questionMapper. selQuestionById(answer. getA_q_id()); selQuestionById.setQ_answerCount(selQuestionById.getQ_answerCount()+1); int updateQuestionIndex = questionMapper. updateQuestion(selQuestionById); return addAnswerIndex+updateQuestionIndex; } /** * Look up the answer below the question * @param q_Id question number */ @Override public List selAllAnswer(int q_Id) { List selAllAnswer = answerMapper. selAllAnswer(q_Id); return selAllAnswer; } @Override public Answer selAnswerByLastId() { Answer selAnswerByLastId = answerMapper. selAnswerByLastId(); return selAnswerByLastId; }…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索