SSM框架bootstrap增删改查和组合分页查询功能管理模块,解决日期字符串自动-1天等问题
推荐文章:
解决JsonFormat日期少一天问题
:https://blog.csdn.net/haitaofeiyang/article/details/51203512
(PS:果然,在知道问题根源后,百度这个问题的描述,找到同样的问题的解决方法的文章等等,是更高效的方法)



本期精彩内容推荐:
解决Ssm框架在执行修改功能时把获得的日期字符串自动-1天的问题
增加功能
修改功能
删除功能
推荐网站
项目运行效果
边看教程视频边做的学习笔记记录
具体代码例子
如何让oracle中的日期增加一天
Userinfo.java
UserinfoSqlMap.xml
注意事项:

登录:http://localhost:8080/Ssmbootstrap2/toLogin
记得UserinfoSqlMap.xml中SQL语句中的sbirth的b是小写的,和bean中的属性对应,如果是大写就会报错
如果登录时报错可能是数据库出现重复数据,建议甚至数据库的用户名列为唯一约束
/*其实private UserCountAllService
的命名可能不一定要和UserCountAllService拼写一样,
且首字母小写,拼写不一样或就是首字母不小写的
UserCountAllService也可以运行成功,效果还是有的,
但为了方便查看而习惯上这样“拼写一样,
且首字母小写”地命名*/
springmvc-servlet.xml中写访问路径
UserinfoSqlMap.xml中写SQL语句部分
项目运行效果:





增加功能 START


增加功能 END

修改功能 START




修改功能 END

删除功能 START




删除功能 END







解决Ssm框架在执行修改功能时把获得的日期字符串自动-1天的问题 START
如何让oracle中的日期增加一天:


解决Ssm框架在执行修改功能时把获得的日期字符串自动-1天的问题 END
边看教程视频边做的学习笔记记录 START



边看教程视频边做的学习笔记记录 END
具体代码例子 START
--drop table Userinfo
create table Userinfo(
id number primary key,
act varchar2(30) not null,
pwd varchar2(30) not null,
birth date
);
--drop sequence seq_Userinfo
create sequence seq_Userinfo
start with 1 --起始值是1
increment by 1 --增长的值
maxvalue 999999999 --序列号的最大值
minvalue 1 --序列号的最小值
nocycle --是否循环
cache 10; --预存
insert into Userinfo values(seq_Userinfo.nextval,'黑黑','pwd1',to_date('2020-06-06','yyyy-mm-dd'));



@DateTimeFormat(pattern="yyyy-MM-dd")//页面写入数据库时格式化
@JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")//数据库导出页面时json格式化


package com.SSHC.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import com.SSHC.bean.Userinfo;
import com.SSHC.service.PubService;
@Controller
public class LoginController {
@Resource
private PubService pubService;
@RequestMapping("RequestMappingLogin")
public String doLogin(@ModelAttribute("SpringWeb") Userinfo u
,HttpSession session,Model m){
u = pubService.login(u);
System.out.println("u:"+u);
if(u != null && u.getId() > 0) {
//将u放到session中去
session.setAttribute("_user", u);
return "index";
} else {
m.addAttribute("msg","登录失败");
return "login";
}
}
}


package com.SSHC.controller;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.SSHC.bean.Userinfo;
import com.SSHC.service.UserCountAllService;
@Controller
public class UserController {
@Resource
private UserCountAllService userCountAllService;
private Map<String,Object>map = new HashMap<String,Object>();
@RequestMapping(value = "ld",method = RequestMethod.GET)
public @ResponseBody Map<String,Object>loadData(@ModelAttribute("SpringWeb") Userinfo u){
System.out.println("每页显示:" + u.getRows());
System.out.println("显示第" + u.getPage() + "页的数据");
System.out.println("输入的查询账号是:" + u.getAct());
System.out.println(u.getSbirth());
System.out.println(u.getEbirth());
//乱码处理
String act = u.getAct();
try {
if(act != null) {
act = new String(act.getBytes("iso8859-1"),"utf-8");
System.out.println(act);
act = "%" + act + "%";
u.setAct(act);
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List<Userinfo>list = userCountAllService.loadAll(u);
map.put("rows", list);
map.put("total", userCountAllService.countAll(u));
return map;
}
@RequestMapping(value = "add",method = RequestMethod.POST)
public @ResponseBody Map<String,Object>doAdd(@ModelAttribute("SpringWeb") Userinfo u){
Integer count = userCountAllService.update(u);
map.put("ct", count);
return map;
}
@RequestMapping(value = "edit",method = RequestMethod.POST)
public @ResponseBody Map<String,Object>doEdit(@ModelAttribute("SpringWeb") Userinfo u){
Integer count = userCountAllService.edit(u);
map.put("ct", count);
return map;
}
@RequestMapping(value = "del",method = RequestMethod.POST)
public @ResponseBody Map<String,Object>doDelete(@ModelAttribute("SpringWeb") Userinfo u){
Integer count = userCountAllService.delete(u.getId());
map.put("ct", count);
return map;
}
}


package com.SSHC.dao;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.SSHC.bean.Userinfo;
@Repository
public interface UserinfoDao {
List<Userinfo> selectAll(Userinfo u);
Userinfo selectByActAndPwd(Userinfo u);
//统计总记录条数的方法
List<Userinfo> totalAll(Userinfo u);
Integer add(Userinfo u);
Integer edit(Userinfo u);
Integer delete(Integer id);
}


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- namespace不能乱写,必须写成IUserinfoDao接口的全路径 -->
<mapper namespace="com.SSHC.dao.UserinfoDao">
<sql id="query">
<where>
<if test="act != null and act.length() > 0">
and act like #{act}
</if>
<if test="sbirth != null">
and birth >= #{sbirth}
</if>
<if test="ebirth != null">
and birth <= #{ebirth}
</if>
</where>
</sql>
<resultMap type="Userinfo" id="rmUserinfo">
<id property="id" column="ID"/>
<result property="act" column="ACT"/>
<result property="pwd" column="PWD"/>
<result property="birth" column="BIRTH"/>
</resultMap>
<select id="selectAll" resultMap="rmUserinfo" parameterType="Userinfo">
select * from
(
select t1.*,rownum rn from
(select * from userinfo
<include refid="query"></include>
) t1
where rownum <= #{end}
)
where rn >= #{start}
</select>
<!-- List<Userinfo> totalAll(Userinfo u) -->
<select id="totalAll" resultMap="rmUserinfo" parameterType="Userinfo">
select * from userinfo
<include refid="query"></include>
</select>
<!-- Userinfo selectByActAndPwd(String act,String pwd) -->
<select id="selectByActAndPwd" resultMap="rmUserinfo"
parameterType="Userinfo">
select * from userinfo where act = #{act}
and pwd = #{pwd}
</select>
<!-- Integer add(Userinfo u); -->
<insert id="add" parameterType="Userinfo">
insert into userinfo(id
<if test="act != null and act.length() > 0">
,act
</if>
<if test="pwd != null and pwd.length() > 0">
,pwd
</if>
<if test="birth != null">
,birth
</if>
) values(seq_userinfo.nextval
<if test="act != null and act.length() > 0">
,#{act}
</if>
<if test="pwd != null and pwd.length() > 0">
,#{pwd}
</if>
<if test="birth != null">
,#{birth}
</if>
)
</insert>
<!-- Integer edit(Userinfo u); -->
<update id="edit" parameterType="Userinfo">
update userinfo
<set>
<if test="act != null and act.length() > 0">
act = #{act},
</if>
<if test="pwd != null and pwd.length() > 0">
pwd = #{pwd},
</if>
<if test="birth != null">
birth =#{birth}
</if>
</set>
<where>
<if test="id != null and id != ''">
and id = #{id}
</if>
</where>
</update>
<!-- Integer delete(Integer id); -->
<delete id="delete">
delete from userinfo where id = #{id}
</delete>
</mapper>


package com.SSHC.service;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.SSHC.bean.Userinfo;
import com.SSHC.dao.UserinfoDao;
@Service
@Transactional
public class PubService {
//属性名就是接口名的首字母改成小写
@Resource
private UserinfoDao userinfoDao;
//登录方法
public Userinfo login(Userinfo u){
return userinfoDao.selectByActAndPwd(u);
}
}


package com.SSHC.service;
import java.util.List;
import com.SSHC.bean.Userinfo;
public interface UserCountAllService {
List<Userinfo>loadAll(Userinfo u);
Integer countAll(Userinfo u);
Integer update(Userinfo u);
Integer edit(Userinfo u);
Integer delete(Integer id);
}


package com.SSHC.service;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.SSHC.bean.Userinfo;
import com.SSHC.dao.UserinfoDao;
@Service
@Transactional
public class UserService implements UserCountAllService {
@Resource
private UserinfoDao userinfoDao;
@Override
public List<Userinfo> loadAll(Userinfo u) {
// TODO Auto-generated method stub
//处理分页参数
Integer page = u.getPage();
Integer rows = u.getRows();
Integer start = (page - 1) * rows + 1;
Integer end = page * rows;
u.setStart(start);
u.setEnd(end);
return userinfoDao.selectAll(u);
}
@Override
public Integer countAll(Userinfo u) {
// TODO Auto-generated method stub
List<Userinfo>list = userinfoDao.totalAll(u);
return list.size();
}
@Override
public Integer update(Userinfo u) {
// TODO Auto-generated method stub
return userinfoDao.add(u);
}
@Override
public Integer edit(Userinfo u) {
// TODO Auto-generated method stub
return userinfoDao.edit(u);
}
@Override
public Integer delete(Integer id) {
// TODO Auto-generated method stub
return userinfoDao.delete(id);
}
}


oracle_drivername=oracle.jdbc.driver.OracleDriver
oracle_url=jdbc:oracle:thin:@localhost:1521:orcl
oracle_username=X
oracle_password=sshcPwd


log4j.rootLogger=DEBUG,Console
#Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d[%t] %-5p [%c] - %m%n
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.org.apache=INFO
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG


<?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.SSHC.bean"/>
</typeAliases>
</configuration>


$(function(){
var oTable = new TableInit();
oTable.init();
//给查询按钮绑定点击事件
$('#btn_query').click(function(){
//刷新表格(会进行分页)
$("#tb_userinfo").bootstrapTable('refresh');
});
//给新增按钮绑定事件
$('#btn_add').click(function(){
//清空表单
clrForm();
//弹出新增界面
$('#win').modal('show');
});
//给表单的提交按钮绑定点击事件
$('#btn_submit').click(function(){
//根据id判断是进行新增还是修改
var id = $('#f_id').val();//id
var url = '';
if(id) {//如果id不为空,就是做修改
url = 'edit';
} else {//否则就是做新增
url = 'add';
}
//获取表单中的输入值
var act = $('#f_act').val();//账号
var p = $('#f_pwd').val();//密码
var p1 = $('#f_cpwd').val();//确认密码
var b = $('#f_birth').val();//生日
if(p === p1) {//如果两次输入的密码一致,就可以提交表单中的数据
$.ajax({
url: url,
type: 'POST',
dataType: 'JSON',
data: {
id: id,
act: act,
pwd: p,
birth: b
},
success: function(data){
var count = data.ct;
if(count > 0) {
//隐藏窗体
$('#win').modal('hide');
//刷新表格
$("#tb_userinfo").bootstrapTable('refresh');
}
}
});
} else {
alert('两次输入的密码不一致');
}
});
//给修改按钮绑定事件
$('#btn_edit').click(function(){
//清空表单
clrForm();
//判断是否选中了一行
var rows = $("#tb_userinfo").bootstrapTable('getSelections');
if(rows.length === 1) {
//获取数据
var id = rows[0].id;
var act = rows[0].act;
var birth = rows[0].birth;
$('#f_id').val(id);
$('#f_act').val(act);
$('#f_birth').val(birth);
//显示弹出窗体
$('#win').modal('show');
} else {
alert('请选择一条记录进行修改');
}
});
//给删除按钮绑定事件
$('#btn_delete').click(function(){
//判断是否选中了一行
var rows = $("#tb_userinfo").bootstrapTable('getSelections');
if(rows.length === 1) {
//获取选中记录的id
var id = rows[0].id;
//提交ajax请求进行删除
$.ajax({
url: 'del',
type: 'POST',
dataType: 'JSON',
data: {
id: id
},
success: function(data){
var count = data.ct;
if(count > 0) {
//刷新表格
$("#tb_userinfo").bootstrapTable('refresh');
}
}
});
} else {
alert('请选择一条记录进行删除');
}
});
})
function clrForm(){
$('#f_id').val('');
$('#f_act').val('');
$('#f_pwd').val('');
$('#f_cpwd').val('');
$('#f_birth').val('');
}
var TableInit = function(){
var objTable = {};
//定义表格的初始化的方法
objTable.init = function(){
$('#tb_userinfo').bootstrapTable({
url: 'ld', //请求后台的URL(*)
method: 'get', //请求方式(*)
contentType: "application/x-www-form-urlencoded",
dataType:'json',//返回的数据类型必须是json对象
toolbar: '#toolbar', //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
pagination: true, //是否显示分页(*)
sortable: false, //是否启用排序
sortOrder: "asc", //排序方式,asc是升序,desc是降序
queryParams: function(params) {
//获取查询输入的条件
var act = $('#s_act').val();
var startBirth = $('#s_birth_start').val();
var endBirth = $('#s_birth_end').val();
var temp = { //这里的键的名字和控制器的变量名必须一致,这边改动,控制器也需要改成一样的
rows: params.limit, //页面大小
page: (params.offset / params.limit) + 1, //页码
act: act,
sbirth: startBirth,
ebirth: endBirth
};
return temp;
}, //传递参数的方法(*)
sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 5, //每页的记录行数(*)
pageList: [2, 3, 5, 10], //可供选择的每页的行数(*)
search: true, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
strictSearch: true,
showColumns: true, //是否显示所有的列
showRefresh: true, //是否显示刷新按钮
minimumCountColumns: 2, //最少允许的列数
clickToSelect: true, //是否启用点击选中行
height: 700, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
uniqueId: "ID", //每一行的唯一标识,一般为主键列
showToggle: true, //是否显示详细视图和列表视图的切换按钮
cardView: false, //是否显示详细视图
detailView: false, //是否显示父子表
onClickRow: function (row) {//点击表格中的某一行时触发这个函数
console.log(row);
},
columns: [{
checkbox: true
}, {
field: 'id',
title: '编号'
}, {
field: 'act',
title: '账号'
}, {
field: 'birth',
title: '生日'
}
, {
field: 'pwd',
title: '密码'
}]
});
}
return objTable;
}


<?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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- 配置扫描注解,不扫描带有@Controller注解的类 -->
<context:component-scan base-package="com.SSHC">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- 引入db.properties文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:db.properties"/>
</bean>
<!--数据库连接池配置-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${oracle_drivername}"/>
<property name="url" value="${oracle_url}"/>
<property name="username" value="${oracle_username}"/>
<property name="password" value="${oracle_password}"/>
</bean>
<!-- 创建sqlSessionFactory对象 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 指定数据源 -->
<property name="dataSource" ref="dataSource"/>
<!-- 指定mybatis框架主配置文件的位置 -->
<property name="configLocation" value="classpath:mybatis.xml"/>
<!-- 自动扫描mapping.xml文件,**表示迭代查找 ,,也可在mybatis.xml中单独指定xml文件 -->
<property name="mapperLocations" value="classpath:com/SSHC/dao/*.xml"/>
</bean>
<!-- 自动扫描com/SSHC/dao下的所有dao接口,并实现这些接口,
可直接在程序中使用dao接口,不用再获取sqlsession对象 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- basePackage 属性是映射器接口文件的包路径。
你可以使用分号或逗号 作为分隔符设置多于一个的包路径-->
<property name="basePackage" value="com/SSHC/dao"/>
<!-- 因为会自动装配 SqlSessionFactory和SqlSessionTemplate
所以没有必要去指定SqlSessionFactory或 SqlSessionTemplate
因此可省略不配置;
但是,如果你使用了一个以上的 DataSource,那么自动装配可能会失效。
这种情况下,你可以使用sqlSessionFactoryBeanName或sqlSessionTemplateBeanName属性
来设置正确的 bean名称来使用 -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 使用声明式事务 transaction-manager:引用上面定义的事务管理器 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>


<body>
<div class="panel-body" style="padding-bottom:0px;">
<!-- 查询面板 -->
<div class="panel panel-default">
<div class="panel-heading">查询条件</div>
<div class="panel-body">
<form id="formSearch" class="form-horizontal">
<div class="form-group" style="margin-top:15px">
<label class="control-label col-sm-1" for="s_act">账号</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="s_act">
</div>
<label class="control-label col-sm-1" for="s_birth">生日起始</label>
<div class="col-sm-2">
<input type="date" class="form-control" id="s_birth_start">
</div>
<label class="control-label col-sm-1" for="s_birth">到</label>
<div class="col-sm-2">
<input type="date" class="form-control" id="s_birth_end">
</div>
<div class="col-sm-3" style="text-align:left;">
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary">查询</button>
</div>
</div>
</form>
</div>
</div>
<!-- 表格上方的工具栏 -->
<div id="toolbar" class="btn-group">
<button id="btn_add" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
</button>
<button id="btn_edit" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
</button>
<button id="btn_delete" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
</button>
</div>
<!-- 数据展示 -->
<table id="tb_userinfo"></table>
</div>
<!-- 弹出窗体 -->
<div class="modal fade" id="win" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<h4 class="modal-title">模块管理</h4>
</div>
<div class="modal-body">
<form id="formSearch" class="form-horizontal">
<input type="hidden" id="f_id" />
<div class="form-group">
<input type="text" class="form-control" id="f_act"
placeholder="账号">
</div>
<div class="form-group">
<input type="password" class="form-control" id="f_pwd"
placeholder="密码" />
<input type="password" class="form-control" id="f_cpwd"
placeholder="确认密码" />
</div>
<div class="form-group">
<input type="text" class="form-control" id="f_birth"
placeholder="生日">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button id="btn_submit" type="button" class="btn btn-primary">提交</button>
</div>
</div>
</div>
</div>
</body>
</html>


<style type="text/css">
*{
font-size: 50px;
}
</style>
</head>
<body>
<form action="RequestMappingLogin" method="post">
<label>账号:</label><input type="text" name="act"/>
<br>
<label>密码:</label><input type="password" name="pwd"/>
<br>
<input type="submit" value="登录" />
</form>
<div>${msg }</div>
</body>
</html>


<?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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<!-- 扫描@Controller注解 -->
<context:component-scan base-package="com.SSHC.controller">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- 默认注册RequestMappingHandlerMapping和RequestMappingHandlerAdapter类 -->
<mvc:annotation-driven />
<!-- jsp引用外部js,css等静态资源的解决方法(和上面的标签必须同时出现,否则无法访问url) -->
<mvc:default-servlet-handler />
<!-- 配置视图名称解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
id="internalResourceViewResolver">
<!-- 前缀 -->
<!-- 将所有的jsp文件存放在/WEB-INF/my/目录下 -->
<property name="prefix" value="/WEB-INF/" />
<!-- 后缀 -->
<property name="suffix" value=".jsp" />
<!-- 优先级设定 -->
<property name="order" value="10"></property>
</bean>
<!-- http://localhost:8080/Ssmbootstrap2/toLogin -->
<mvc:view-controller path="/toLogin" view-name="login"/>
</beans>


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Ssmbootstrap2</display-name>
<!-- springcore框架配置 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- controller中文乱码处理,注意一点:要配置在所有过滤器的前面 -->
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- springmvc框架配置 -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

具体代码例子 END

https://v4.bootcss.com/docs/content/reboot/

