毕业设计回顾

 

2020-04-03

service

package com.ahpu.service.impl;

import com.ahpu.mapper.UserMapper;
import com.ahpu.pojo.User;
import com.ahpu.pojo.UserExample;
import com.ahpu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
    public void add(User u) {
        userMapper.insert(u);
    }

    @Override
    public void delete(Integer number) {
        userMapper.deleteByPrimaryKey(number);
    }

    @Override
    public void update(User u) {
        userMapper.updateByPrimaryKey(u);
    }

    @Override
    public User get(Integer number, String password) {
        System.out.println(userMapper.selectByPrimaryKey(number));

        for(int i=0;i<10;i++) System.out.println(i);

        return userMapper.selectByPrimaryKey(number);

//     
    }

}

  Mapper

package com.ahpu.mapper;

import com.ahpu.pojo.User;
import com.ahpu.pojo.UserExample;

import java.util.List;

public interface UserMapper {
    int deleteByPrimaryKey(Integer number);

    int insert(User record);


    User selectByPrimaryKey(Integer number);


    int updateByPrimaryKey(User record);
}

  Controller

@RequestMapping("loginForm")
    public String login(@RequestParam("number") int number, @RequestParam("password") String password, Model model, HttpSession session) {
      //  number = HtmlUtils.htmlEscape(number);

        User user = userService.get(number,password);
        if(null==password){
            model.addAttribute("msg", "账号密码错误");
            return "/signUp";
        }
        session.setAttribute("user", user);
        return "redirect:loginsuccess";
    }

 Mapper.xml

<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultType="com.ahpu.pojo.User">
        select
        *
        from user
        where number = #{number,jdbcType=INTEGER}
    </select>

  error

消息 Request processing failed; nested exception is java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.ahpu.mapper.UserMapper.selectByPrimaryKey

已解决:

 mapper.xml

 

 

 路径写错:

<mapper namespace="com.ahpu.mapper.UserMapper">

 

 


 

 修改之后迎来下一个错误:

消息 Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.String

 已解决:

mybatis下的JdbcType只能为:

BIT FLOAT CHAR TIMESTAMP OTHER UNDEFINED

TINYINT REAL VARCHAR BINARY BLOB NVARCHAR

SMALLINT DOUBLE LONGVARCHAR VARBINARY CLOB NCHAR

INTEGER NUMERIC DATE LONGVARBINARY BOOLEAN NCLOB

BIGINT DECIMAL TIME NULL CURSOR


 

2020-4-4

在对所有的jsp页面进行重构之后发现除了主页之外访问任何页面都会404,包括静态图片。经检查有以下几个问题:

SpringMVC.xml文件下的路径没有及时更改

 

 但是修改之后情况还是没有变化,看网上说的大概是在web.xml文件中对所有的静态文件进行了拦截,但是按照网上的步骤还是无法进行更改,于是仿照Controller的写法,写了个转换

package com.ahpu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("")
public class PageController {
    @RequestMapping("signUp")
    public String signUp() {
        return "fore/signUp";
    }
    @RequestMapping("zxxx")
    public String zxxx() {
        return "fore/zxxx";
    }
    @RequestMapping("xyxw")
    public String zyxw() {
        return "fore/xyxw";
    }
    @RequestMapping("dyfc")
    public String dyfc(){
        return "fore/dyfc";
    }
    @RequestMapping("loginsuccess")
    public String loginsuccess(){
        return "fore/loginsuccess";
    }

}

  但是应该注意,在herf和Controller中都不要出现.jsp

 


我就是一个只知道cv大法的小菜鸡

完成了editormd的功能按钮拓展以及预览页面

就是抄https://www.jianshu.com/p/9d245837aa4c大佬的

 


form表单提交到controller获取不到内容,是因为提交时要保证提交的文字区名(不是表单名!!!!!!)要和controller对应

 

 这里就应该是content而不是editormd或者mdEditorForm

controller

@RequestMapping("contentCommit")
    public ModelAndView contentCommit(@RequestParam("content") String  content){
        System.out.println("提交的内容为:" + content);
        ModelAndView modelAndView = new ModelAndView("admin/preview");
        //将内容发送至前台预览
        modelAndView.addObject("viewContent" , content);
        System.out.println("跳转至内容显示页面");
        return modelAndView;
    }

  



 

5-22

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roomController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.ahpu.service.RoomService com.ahpu.controller.RoomController.roomService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.ahpu.service.RoomService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

 

ServiceImpl没加@service注释

 Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrController’ bean method

控制层同一请求映射到两个方法,检查@RequestMapping(value = “请求方法名”)是否重复

 

 



5-24

Mapped Statements collection does not contain value for

 

 

<mapper namespace="mapper.TopicMapper" >    -》      <mapper namespace="com.ahpu.mapper.TopicMapper" >


posted on 2020-04-02 15:15  妄想症T  阅读(194)  评论(0编辑  收藏  举报

导航