各位好,自己练习ssm基础框架搭建时候,遇到页面跳转500问题。
之前跟着教程写过一个完整的ssm框架CRUD。运行没问题。
后来练习搭建简单SSM框架,测试就出问题。代码和之前写的一摸一样。求解惑
自己的工程
mapper接口
package com.tsm.dao;
import com.tsm.pojo.Books;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BookMapper {
int addBook(Books books);
int deleteBookById(@Param("bookId")int id);
int updateBook(Books books);
Books queryBookById(@Param("bookId")int id);
List<Books> queryAllBook();
}
mapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tsm.dao.BookMapper">
<insert id="addBook" parameterType="books">
insert into ssmp.books (bookName, bookCounts, detail)
VALUES (#{bookName}, #{bookCounts}, #{detail});
</insert>
<delete id="deleteBookById" parameterType="int">
delete
from ssmp.books
where bookID = #{bookId}
</delete>
<update id="updateBook" parameterType="books">
update ssmp.books
set bookName=#{bookName},
bookCounts=#{bookCounts},
detail=#{detail}
where bookID = #{bookID};
</update>
<select id="queryBookById" resultType="books">
select *
from ssmp.books
where bookID = #{bookId}
</select>
<select id="queryAllBook" resultType="books">
select *
from ssmp.books
</select>
</mapper>
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<package name="com.tsm.pojo"/>
</typeAliases>
<mappers>
<mapper class="com.tsm.dao.BookMapper"/>
</mappers>
</configuration>
spring-dao.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder location="classpath:database.properties"/>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driver}"></property>
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="user" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<property name="maxPoolSize" value="30"/>
<property name="minPoolSize" value="10"/>
<property name="autoCommitOnClose" value="false"/>
<property name="checkoutTimeout" value="10000"/>
<property name="acquireRetryAttempts" value="2"/>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:mybatis-config.xml"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
<property name="basePackage" value="com.tsm.dao"/>
</bean>
</beans>
controller
package com.tsm.controller;
import com.tsm.pojo.Books;
import com.tsm.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
@Controller
@RequestMapping("/book")
public class BookController {
@Autowired
@Qualifier("BookServiceImpl")
private BookService bookService;
@RequestMapping("/allBook")
public String list(Model model){
List<Books> list = bookService.queryAllBook();
model.addAttribute("list",list);
return "allBook";
}
}
怎么查都查不到解决方法。