本章讲解springboot实现web开发中涉及的一些常用的功能进行详细讲解
5.1 SpringMvc整合
5.1.1springmvc自动化配置
springboot引入web依赖启动器spring-boot-starter------web就可以不用再额外配置其他的东西就可以进行web开发啦。
1.内置两个视图解析器(视图解析器的作用是将逻辑视图名称解析成实际的视图对象,以便最终在浏览器中呈现给用户。例如,当用户请求一个 URL 时,控制器可以返回一个逻辑视图名称为 "home",而视图解析器会将其解析成一个 JSP 页面,最终在浏览器中渲染出来。):
5.1.2springmvc功能拓展实现
在实际开发中还需要开发者对一些功能进行扩展实现,下面通过案例进行讲解;
1.创建案例:springboot的案例如下添加的依赖:并且把第四章的案例的一些文件复制过来
目录如下:
2.拓展功能的实现:
我们springboot整合springmvc进行web开发,实现简单的页面跳转功能。
1.注册视图管理器:
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//该类用于对mvc框架功能进行扩展
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
//添加视图管理,实现WebMvcConfigurer接口的下面那个方法
@Override
public void addViewControllers(ViewControllerRegistry registry) {
//请求/toLoginPage映射或者login.html页面都会自动映射到login。html页面,setViewName("login");的作用是映射路径为login.html页面
registry.addViewController("/login.html").setViewName("login");
registry.addViewController("/toLoginPage").setViewName("login");
}
}
需要关闭传统的LoginController控制器。
使用这个方法进行视图界面的控制,很简单。我个人理解就是:替代啦传统的页面访问方式,就可以进行页面的控制,你在浏览器框输入自己规定的页面链接就可以访问到自己想访问到的界面。
就是参数之间没有互相传送,也就是说明说的。
2.自定义拦截器
WebMvcConfigurer接口提供啦许多MVC开发的相关方法,接下来我们使用相关方法进行注册自定义拦截器:
1.定义拦截器类,并编写简单的拦截器业务代码:
HttpServletRequest
它封装了客户端发送的HTTP请求。当客户端通过HTTP协议访问服务器时,请求中的所有信息,包括请求头、参数等,都被封装在HttpServletRequest对象中。通过HttpServletRequest提供的方法,可以获取到这些信息。
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import java.util.Calendar;
/**
* 自定义一个拦截器类
*/
@Component
public class MyInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
// 用户请求/admin开头路径时,判断用户是否登录
String uri = request.getRequestURI();//接受客户端请求过来的请求路径
Object loginUser = request.getSession().getAttribute("loginUser");
//如果用户请求以/admin开头,就判断用户是否登录,如果没有登录,就重定向到"/toLoginPage",请求对应的登录页面。
if (uri.startsWith("/admin") && null == loginUser) {
response.sendRedirect("/toLoginPage");
return false;
}
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response,
Object handler, @Nullable ModelAndView modelAndView) throws Exception {
//使用request对象向前端页面传递表示年份的currentYear数据
request.setAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse
response, Object handler, @Nullable Exception ex) throws Exception {
}
}
2.在mvc扩展功能的类
MyMvcConfig中扩展拦截器
//重写addInterceptors方法注册定义的拦截器
//引入自定义的MyInterceptor拦截器组件
@Autowired
private MyInterceptor myInterceptor;
//添加拦截器管理,重写addInterceptors方法,注册自定义的拦截器,
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(myInterceptor)
// 拦截所有 路径请求
.addPathPatterns("/**")
//对/login.html路径进行放行
.excludePathPatterns("/login.html");
}
访问路径:http://localhost:8080/admin
自动跳转到登录页面,同时动态显示出当前年份,说明拦截器定制成功啦。
5.2springboot整合servlet三大组件
servlet三大组件:Servlet 、Filter 和Listener。
Servlet是JavaWeb的核心组件之一,主要负责处理客户端的请求和生成动态内容。
Filter,即过滤器,是用于拦截请求和响应的组件。
Listener,即监听器,用于监听和响应应用程序事件。
springboot提供啦组件注册和路径扫描两种方式整合servlet三大组件,接下来讲解这两种方式:
1.使用组件注册方式整合servlet:
创建自定义类:servlet类。
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import java.io.IOException;
/*
自定义servlet类
*/
@Component//将类作为主键注入spring容器中
public class MyServlet extends HttpServlet {
/**
* 通过HttpServletResponse向页面输出helloMyServlet
* @param req
* @param resp
* @throws ServletException
* @throws IOException
*/
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//调用本类中的doPost方法,把值传到客户端
this.doPost(req, resp);
}
//该方法定义resp.getWriter().write,向客户端响应信息
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().write("hello,fanronglou");
}
}
创建servlet配置类:
import com.waiguoyu.day5.servletComponent.MyServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 用来对servlet相关组件进行注册
*/
@Configuration//标记类为配置类
public class ServletConfig {
//注册servlet组件,getServlet注册前面自定义的MyServlet组件,返回ServletRegistrationBean类型的bean对象
@Bean
public ServletRegistrationBean getServlet(MyServlet myservlet) {
ServletRegistrationBean servletRegistrationBean =
//这里设置访问路径为/servlet出发自定义的servlet组件
new ServletRegistrationBean(myservlet,"/servlet");
return servletRegistrationBean;
}
}
访问地址:http://localhost:8080/servlet
如果调试成功就代表整合sevlet成功。
使用组件注册方式整合Filter
整合的思路是一样的,这里进行代码讲解:
创建自定义类:
import jakarta.servlet.*;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
* 自定义Filter类
*/
@Component//将Myfiltet类作为组件注入spring容器中
public class MyFilter implements Filter {
// 重写接口的方法
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
// 向控制台输出字符串
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
System.out.println("MyFilter");
filterChain.doFilter(servletRequest, servletResponse);
}
@Override
public void destroy() {
}
}
注册组件:
@Bean//这个方法反回组装好的registrationBean对象,@bean将registrationBean对象作为bean组件返回
public FilterRegistrationBean getFilter(MyFilter myfilter) {
FilterRegistrationBean registrationBean =
new FilterRegistrationBean(myfilter);
//设置过滤的请求路径为"/toLoginPage","/myFilter",
registrationBean.setUrlPatterns(Arrays.asList("/toLoginPage","/myFilter"));
return registrationBean;
}
测试:http://localhost:8080/myFilter
由于没有编写对应路径的处理方法,所以会404,只需要看控制器的信息就知道整合成功啦不。
使用组件注册方法整合Listener
流程一样:
创建自定义的Listener类:
import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
import org.springframework.stereotype.Component;
/**
* MyListener
*/
@Component
public class MyListener implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent sce) {
System.out.println("contextDestroyed");
}
@Override
public void contextInitialized(ServletContextEvent sce) {
System.out.println("MyListener contextInitialized");
}
}
Serlvet容器提供啦很多listener接口,我们可以根据自己的需求选择对应接口实现就可以啦。
注册组件:
@Bean
public ServletListenerRegistrationBean getServletListener(MyListener mylistener) {
ServletListenerRegistrationBean servletListenerRegistrationBean=
new ServletListenerRegistrationBean(mylistener);
return servletListenerRegistrationBean;
}
启动程序:
启动项目和关闭项目之后有这两个语句就算整合成功啦。
如果注释掉注册类,servlet组件仍然生效。
5.2.2 路径扫描整合Servlet三大组
使用这个方式扫描三大件时,需要在自定义组件上添加:这三个注解进行声明,并且配置相关注解属性,在项目主程序上用特定的注解开启组件扫描就可以啦
我们在上一节的案例上进行操作:
1.使用路径扫描方式整合servlet三大件:
避免与之前的注册方式干扰,我们将之前定义的组件配置类(也就是进行注册组件的类)注释掉。
还注释掉三大组件上的@Component注解。
/**
* 自定义Filter类
*/
@WebFilter(value = {"/antionLogin","/antionMyFilter"})
//@Component//将Myfiltet类作为组件注入spring容器中
public class MyFilter implements Filter {
// 重写接口的方法
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
// 向控制台输出字符串
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
System.out.println("MyFilter");
filterChain.doFilter(servletRequest, servletResponse);
}
@Override
public void destroy() {
}
}
自定义servlet类
*/
@WebServlet("/annotationServlet")
//@Component//将类作为主键注入spring容器中
public class MyServlet extends HttpServlet {
/**
* 通过HttpServletResponse向页面输出helloMyServlet
* @param req
* @param resp
* @throws ServletException
* @throws IOException
*/
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().write("hello,fanronglou");
}
}
*/
@WebListener
//@Component
public class MyListener implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent sce) {
System.out.println("contextDestroyed");
}
@Override
public void contextInitialized(ServletContextEvent sce) {
System.out.println("MyListener contextInitialized");
}
}
在主程序上添加注解对组件扫描:
@SpringBootApplication
@ServletComponentScan
public class Day5Application {
public static void main(String[] args) {
SpringApplication.run(Day5Application.class, args);
}
}
进行对应的测试,就成功啦。
这里就讲解成功springboot整合servlet三大组件的方法。大家可以根据需求进行使用。
5.3 文件上传下载
5.3.1 文件上传
web开发中,这个功能很常见,浏览器通过表单形式将文件以流的形式传递给服务器,服务器再对上传的数据解析处理。
下面我们对这个操作进行案例讲解:
1.编写文件上传的表单页面
在根目录下创建upload.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>动态添加文件上传列表</title>
<link th:href="@{/login/css/bootstrap.min.css}" rel="stylesheet">
<!-- 引入静态资源/login/js/jquery.min.js-->
<script th:src="@{/login/js/jquery.min.js}"></script>
</head>
<body>
<div th:if="${uploadStatus}" style="color: red" th:text="${uploadStatus}">上传成功</div>
<!--这里用于创建上传文件的表单-->
<form th:action="@{/uploadFile}" method="post" enctype="multipart/form-data">
上传文件: <input type="button" value="添加文件" onclick="add()"/>
<div id="file" style="margin-top: 10px;" th:value="文件上传区域"> </div>
<input id="submit" type="submit" value="上传"
style="display: none;margin-top: 10px;"/>
</form>
<!--这里用于处理用户动态添加或者移除上传输入框,这是一段js代码-->
<script type="text/javascript">
// 动态添加上传按钮
function add(){
var innerdiv = "<div>";
innerdiv += "<input type='file' name='fileUpload' required='required'>" +
"<input type='button' value='删除' onclick='remove(this)'>";
innerdiv +="</div>";
$("#file").append(innerdiv);
// 打开上传按钮
$("#submit").css("display","block");
}
// 删除当前行<div>
function remove(obj) {
$(obj).parent().remove();
if($("#file div").length ==0){
$("#submit").css("display","none");
}
}
</script>
</body>
</html>
添加静态资源:
/*! jQuery v2.2.3 | (c) jQuery Foundation | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.toString,k=i.hasOwnProperty,l={},m="2.2.3",n=function(a,b){return new n.fn.init(a,b)},o=/^[s??]+|[s??]+$/g,p=/^-ms-/,q=/-([da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return e.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a){return n.each(this,a)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(e.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:g,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=a&&a.toString();return!n.isArray(a)&&b-parseFloat(b)+1>=0},isPlainObject:function(a){var b;if("object"!==n.type(a)||a.nodeType||n.isWindow(a))return!1;if(a.constructor&&!k.call(a,"constructor")&&!k.call(a.constructor.prototype||{},"isPrototypeOf"))return!1;for(b in a);return void 0===b||k.call(a,b)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?i[j.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=d.createElement("script"),b.text=a,d.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b){var c,d=0;if(s(a)){for(c=a.length;c>d;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):g.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:h.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,g=0,h=[];if(s(a))for(d=a.length;d>g;g++)e=b(a[g],g,c),null!=e&&h.push(e);else for(g in a)e=b(a[g],g,c),null!=e&&h.push(e);return f.apply([],h)},guid:1,proxy:function(a,b){var c,d,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(d=e.call(arguments,2),f=function(){return a.apply(b||this,d.concat(e.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:l}),"function"==typeof Symbol&&(n.fn[Symbol.iterator]=c[Symbol.iterator]),n.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){i["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=!!a&&"length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ga(),z=ga(),A=ga(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\x20\t\r
\f]",M="(?:\.|[\w-]|[^\x00-\xa0])+",N="["+L+"*("+M+")(?:"+L+"*([*^KaTeX parse error: Got function '\\' with no arguments as superscript at position 28: ...*(?:'((?:\\.|[^\̲\̲'])*)'|"((?:\\....","g"),R=new RegExp("^"+L+","+L+" "),S=new RegExp("^"+L+"([>+~]|"+L+")"+L+" "),T=new RegExp("="+L+"([^]'"] ?)"+L+"]","g"),U=new RegExp(O),V=new RegExp("^"+M+"KaTeX parse error: Expected group after '^' at position 22: ...ID:new RegExp("^̲#("+M+")"),CLAS...","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?😦"+L+"*((?:-\d)?\d*)"+L+"*)|)(?=[^-]|KaTeX parse error: Expected 'EOF', got '}' at position 8: )","i")}̲,X=/^(?:input|s.../i,Y=/^hdKaTeX parse error: Double superscript at position 9: /i,Z=/^[^̲{]+{s*[native w...=/^(?:#([w-]+)|(w+)|.([w-]+))KaTeX parse error: Undefined control sequence: \/ at position 18: ..._=/[+~]/,aa=/'|\̲/̲g,ba=new RegExp....exec(a)))if(f=o[1]){if(9=x){if(!(j=b.getElementById(f)))return d;if(j.id=f)return d.push(j),d}else if(w&&(j=w.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(o[2])return H.apply(d,b.getElementsByTagName(a)),d;if((f=o[3])&&c.getElementsByClassName&&b.getElementsByClassName)return H.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==x)w=b,s=a;else if("object"!b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(aa,"\&"):b.setAttribute("id",k=u),r=g(a),h=r.length,l=V.test(k)?"#"+k:"\[id='"+k+"'\]";while(h--)r\[h\]=l+" "+qa(r\[h\]);s=r.join(","),w=_.test(a)\&\&oa(b.parentNode)\|\|b}if(s)try{return H.apply(d,w.querySelectorAll(s)),d}catch(y){}finally{k=u\&\&b.removeAttribute("id")}}}return i(a.replace(Q,"KaTeX parse error: Expected 'EOF', got '}' at position 11: 1"),b,d,e)}̲function ga(){v...\]="+L+"* (?:''\|"")"),a.querySelectorAll("\[selected\]").length\|\|q.push("\["+L+"*(?:value\|"+K+")"),a.querySelectorAll("\[id~="+u+"-\]").length\|\|q.push("~="),a.querySelectorAll(":checked").length\|\|q.push(":checked"),a.querySelectorAll("a#"+u+"+* ").length\|\|q.push(".#.+\[+\~\]")}),ia(function(a){var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("\[name=d\]").length\&\&q.push("name"+L+"*\[* \^|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll(",:x"),q.push(",.* :")})),(c.matchesSelector=Z.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ia(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",O)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Z.test(o.compareDocumentPosition),t=b||Z.test(o.contains)?function(a,b){var c=9=a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a=d||!(!d||1!d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b=a)return!0;return!1},B=b?function(a,b){if(a=b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)=(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)=d?a=n||a.ownerDocument=v&&t(v,a)?-1:b=n||b.ownerDocument=v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a=b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a=n?-1:b=n?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return ka(a,b);c=a;while(c=c.parentNode)g.unshift©;c=b;while(c=c.parentNode)h.unshift©;while(g[d]===h[d])d++;return d?ka(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},fa.matches=function(a,b){return fa(a,null,null,b)},fa.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(T,"='KaTeX parse error: Expected 'EOF', got '&' at position 24: ...matchesSelector&̲&p&&!A[b+" "]&&...)"))&&y(a,function(a){return b.test("string"typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fa.attr(d,a);return nulle?"!="===b:b?(e+="","="=b?e=c:"!="=b?e!c:"^="=b?c&&0=e.indexOf©:"*="=b?c&&e.indexOf©>-1:"$="=b?c&&e.slice(-c.length)=c:"~="=b?(" "+e.replace(P," ")+" ").indexOf©>-1:"|="=b?e=c||e.slice(0,c.length+1)=c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!a.slice(0,3),g="last"!a.slice(-4),h="of-type"=b;return 1=d&&0=e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while§{m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()=r:1=m.nodeType)return!1;o=p="only"=a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]=w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1=m.nodeType&&++t&&m=b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]=w&&j[1],t=n),t=!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()=r:1=m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m=b))break;return t-=e,t=d||t%d=0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fa.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ha(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ha(function(a){var b=[],c=[],d=h(a.replace(Q,"$1"));return d[u]?ha(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ha(function(a){return function(b){return fa(a,b).length>0}}),contains:ha(function(a){return a=a.replace(ba,ca),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ha(function(a){return V.test(a||"")||fa.error("unsupported lang: "+a),a=a.replace(ba,ca).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c=a||0=c.indexOf(a+"-");while((b=b.parentNode)&&1=b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)=b.id},root:function(a){return a=o},focus:function(a){return a=n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled=!1},disabled:function(a){return a.disabled=!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"=b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected=!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Y.test(a.nodeName)},input:function(a){return X.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"=a.nodeName.toLowerCase()&&"text"=a.type&&(null(b=a.getAttribute("type"))||"text"=b.toLowerCase())},first:na(function(){return[0]}),last:na(function(a,b){return[b-1]}),eq:na(function(a,b,c){return[0>c?c+b:c]}),even:na(function(a,b){for(var c=0;b>c;c+=2)a.push©;return a}),odd:na(function(a,b){for(var c=1;b>c;c+=2)a.push©;return a}),lt:na(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:na(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=la(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=ma(b);function pa(){}pa.prototype=d.filters=d.pseudos,d.setFilters=new pa,g=fa.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){c&&!(e=R.exec(h))||(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=S.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(Q," ")}),h=h.slice(c.length));for(g in d.filter)!(e=W[g].exec(h))||j[g]&&!(e=jg)||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?fa.error(a)😒(a,i).slice(0)};function qa(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function ra(a,b,c){var d=b.dir,e=c&&"parentNode"=d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1=b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j,k=[w,f];if(g){while(b=b[d])if((1=b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1=b.nodeType||e){if(j=b[u]||(b[u]={}),i=j[b.uniqueID]||(j[b.uniqueID]={}),(h=i[d])&&h[0]=w&&h[1]=f)return k[2]=h[2];if(i[d]=k,k[2]=a(b,c,g))return!0}}}function sa(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!ae)return!1;return!0}:a[0]}function ta(a,b,c){for(var d=0,e=b.length;e>d;d++)fa(a,b[d],c);return c}function ua(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(c&&!c(f,d,e)||(g.push(f),j&&b.push(h)));return g}function va(a,b,c,d,e,f){return d&&!d[u]&&(d=va(d)),e&&!e[u]&&(e=va(e,f)),ha(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ta(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ua(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ua(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ua(r=g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function wa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ra(function(a){return a=b},h,!0),l=ra(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[ra(sa(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return va(i>1&&sa(m),i>1&&qa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"":""})).replace(Q,"KaTeX parse error: Expected 'EOF', got '&' at position 10: 1"),c,e>i&̲&wa(a.slice(i,e.../,y=/^.[^:#[.,] KaTeX parse error: Expected '}', got '&' at position 334: ...d=b[0];return c&̲&(a=":not("+a+".../,C=n.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||A,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:B.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),x.test(e[1])&&n.isPlainObject(b))for(e in b)n.isFunction(this[e])?thise:this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&f.parentNode&&(this.length=1,this[0]=f),this.context=d,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?void 0!c.ready?c.ready(a):a(n):(void 0!a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};C.prototype=n.fn,A=n(d);var D=/^(?:parents|prev(?:Until|All))/,E={children:!0,contents:!0,next:!0,prev:!0};n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=w.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!b;c=c.parentNode)if(c.nodeType<11&&(g?g.index©>-1:1=c.nodeType&&n.find.matchesSelector(c,a))){f.push©;break}return this.pushStack(f.length>1?n.uniqueSort(f):f)},index:function(a){return a?"string"typeof a?h.call(n(a),this[0]):h.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.uniqueSort(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(nulla?this.prevObject:this.prevObject.filter(a))}});function F(a,b){while((a=a[b])&&1!a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!b.nodeType?b:null},parents:function(a){return u(a,"parentNode")},parentsUntil:function(a,b,c){return u(a,"parentNode",c)},next:function(a){return F(a,"nextSibling")},prev:function(a){return F(a,"previousSibling")},nextAll:function(a){return u(a,"nextSibling")},prevAll:function(a){return u(a,"previousSibling")},nextUntil:function(a,b,c){return u(a,"nextSibling",c)},prevUntil:function(a,b,c){return u(a,"previousSibling",c)},siblings:function(a){return v((a.parentNode||{}).firstChild,a)},children:function(a){return v(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!a.slice(-5)&&(d=c),d&&"string"typeof d&&(e=n.filter(d,e)),this.length>1&&(E[a]||n.uniqueSort(e),D.test(a)&&e.reverse()),this.pushStack(e)}});var G=/S+/g;function H(a){var b={};return n.each(a.match(G)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"typeof a?H(a):n.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h<f.length)f[h].apply(c[0],c[1])=!1&&a.stopOnFalse&&(h=f.length,c=!1)}a.memory||(c=!1),b=!1,e&&(f=c?[]:"")},j={add:function(){return f&&(c&&!b&&(h=f.length-1,g.push©),function d(b){n.each(b,function(b,c){n.isFunction©?a.unique&&j.has©||f.push©:c&&c.length&&"string"!n.type©&&d©})}(arguments),c&&!b&&i()),this},remove:function(){return n.each(arguments,function(a,b){var c;while((c=n.inArray(b,f,c))>-1)f.splice(c,1),h>=c&&h--}),this},has:function(a){return a?n.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push©,b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function©{n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().progress(c.notify).done(c.resolve).fail(c.reject):cf[0]+"With"})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return ef[0]+"With",this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=e.call(arguments),d=c.length,f=1!d||a&&n.isFunction(a.promise)?d:0,g=1=f?a:n.Deferred(),h=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?e.call(arguments):d,c=i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(d>1)for(i=new Array(d),j=new Array(d),k=new Array(d);d>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().progress(h(b,j,i)).done(h(b,k,c)).fail(g.reject):--f;return f||g.resolveWith(k,c),g.promise()}});var I;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a=!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!!0&&--n.readyWait>0||(I.resolveWith(d,[n]),n.fn.triggerHandler&&(n(d).triggerHandler("ready"),n(d).off("ready"))))}});function J(){d.removeEventListener("DOMContentLoaded",J),a.removeEventListener("load",J),n.ready()}n.ready.promise=function(b){return I||(I=n.Deferred(),"complete"=d.readyState||"loading"!d.readyState&&!d.documentElement.doScroll?a.setTimeout(n.ready):(d.addEventListener("DOMContentLoaded",J),a.addEventListener("load",J))),I.promise(b)},n.ready.promise();var K=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=nullc;if("object"=n.type©){e=!0;for(h in c)K(a,b,h,c[h],!0,f,g)}else if(void 0!d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},L=function(a){return 1=a.nodeType||9=a.nodeType||!+a.nodeType};function M(){this.expando=n.expando+M.uid++}M.uid=1,M.prototype={register:function(a,b){var c=b||{};return a.nodeType?a[this.expando]=c:Object.defineProperty(a,this.expando,{value:c,writable:!0,configurable:!0}),a[this.expando]},cache:function(a){if(!L(a))return{};var b=a[this.expando];return b||(b={},L(a)&&(a.nodeType?a[this.expando]=b:Object.defineProperty(a,this.expando,{value:b,configurable:!0}))),b},set:function(a,b,c){var d,e=this.cache(a);if("string"typeof b)e[b]=c;else for(d in b)e[d]=b[d];return e},get:function(a,b){return void 0=b?this.cache(a):a[this.expando]&&a[this.expando][b]},access:function(a,b,c){var d;return void 0=b||b&&"string"typeof b&&void 0=c?(d=this.get(a,b),void 0!d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!c?c:b)},remove:function(a,b){var c,d,e,f=a[this.expando];if(void 0!f){if(void 0=b)this.register(a);else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in f?d=[b,e]:(d=e,d=d in f?[d]:d.match(G)||[])),c=d.length;while(c--)delete f[d[c]]}(void 0=b||n.isEmptyObject(f))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(a){var b=a[this.expando];return void 0!b&&!n.isEmptyObject(b)}};var N=new M,O=new M,P=/^(?:{[wW]}|[[wW] ])KaTeX parse error: Expected '}', got '&' at position 51: ...d;if(void 0===c&̲&1===a.nodeType...&").toLowerCase(),c=a.getAttribute(d),"string"typeof c){try{c="true"=c?!0:"false"=c?!1:"null"=c?null:+c+""=c?+c:P.test©?n.parseJSON©:c;
}catch(e){}O.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return O.hasData(a)||N.hasData(a)},data:function(a,b,c){return O.access(a,b,c)},removeData:function(a,b){O.remove(a,b)},_data:function(a,b,c){return N.access(a,b,c)},_removeData:function(a,b){N.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0=a){if(this.length&&(e=O.get(f),1=f.nodeType&&!N.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0=d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),R(f,d,e[d])));N.set(f,"hasDataAttrs",!0)}return e}return"object"typeof a?this.each(function(){O.set(this,a)}):K(this,function(b){var c,d;if(f&&void 0=b){if(c=O.get(f,a)||O.get(f,a.replace(Q,"-KaTeX parse error: Expected 'EOF', got '&' at position 1: &̲").toLowerCase(...","i"),U=["Top","Right","Bottom","Left"],V=function(a,b){return a=b||a,"none"=n.css(a,"display")||!n.contains(a.ownerDocument,a)};function W(a,b,c,d){var e,f=1,g=20,h=d?function(){return d.cur()}:function(){return n.css(a,b,"")},i=h(),j=c&&c[3]||(n.cssNumber[b]?"":"px"),k=(n.cssNumber[b]||"px"!j&&+i)&&T.exec(n.css(a,b));if(k&&k[3]!j){j=j||k[3],c=c||[],k=+i||1;do f=f||".5",k/=f,n.style(a,b,k+j);while(f!(f=h()/i)&&1!f&&--g)}return c&&(k=+k||+i||0,e=c[1]?k+(c[1]+1)c[2]:+c[2],d&&(d.unit=j,d.start=k,d.end=e)),e}var X=/^(?:checkbox|radio)KaTeX parse error: Expected group after '^' at position 21: .../<([w:-]+)/,Z=/^̲|/(?:java|ecma)script/i, = o p t i o n : [ 1 , " < s e l e c t m u l t i p l e = ′ m u l t i p l e ′ > " , " < / s e l e c t > " ] , t h e a d : [ 1 , " < t a b l e > " , " < / t a b l e > " ] , c o l : [ 2 , " < t a b l e > < c o l g r o u p > " , " < / c o l g r o u p > < / t a b l e > " ] , t r : [ 2 , " < t a b l e > < t b o d y > " , " < / t b o d y > < / t a b l e > " ] , t d : [ 3 , " < t a b l e > < t b o d y > < t r > " , " < / t r > < / t b o d y > < / t a b l e > " ] , d e f a u l t : [ 0 , " " , " " ] ; ={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]}; =option:[1,"<selectmultiple=′multiple′>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],default:[0,"",""];.optgroup= . o p t i o n , .option, .option,.tbody= . t f o o t = .tfoot= .tfoot=.colgroup= . c a p t i o n = .caption= .caption=.thead, . t h = .th= .th=.td;function _(a,b){var c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||""):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0=b||b&&n.nodeName(a,b)?n.merge([a],c):c}function aa(a,b){for(var c=0,d=a.length;d>c;c++)N.set(a[c],"globalEval",!b||N.get(b[c],"globalEval"))}var ba=/<|&#?w+;/;function ca(a,b,c,d,e){for(var f,g,h,i,j,k,l=b.createDocumentFragment(),m=[],o=0,p=a.length;p>o;o++)if(f=a[o],f||0=f)if("object"=n.type(f))n.merge(m,f.nodeType?[f]:f);else if(ba.test(f)){g=g||l.appendChild(b.createElement("div")),h=(Y.exec(f)||["",""])[1].toLowerCase(),i= [ h ] ∣ ∣ [h]|| [h]∣∣.default,g.innerHTML=i[1]+n.htmlPrefilter(f)+i[2],k=i[0];while(k--)g=g.lastChild;n.merge(m,g.childNodes),g=l.firstChild,g.textContent=""}else m.push(b.createTextNode(f));l.textContent="",o=0;while(f=m[o++])if(d&&n.inArray(f,d)>-1)e&&e.push(f);else if(j=n.contains(f.ownerDocument,f),g= (l.appendChild(f),"script"),j&&aa(g),c){k=0;while(f=g[k++])Z.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild©,l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="x",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var da=/^key/,ea=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,fa=/^([^.]*)(?:.(.+)|)/;function ga(){return!0}function ha(){return!1}function ia(){try{return d.activeElement}catch(a){}}function ja(a,b,c,d,e,f){var g,h;if("object"typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)ja(a,h,c,d,b[h],f);return a}if(nulld&&nulle?(e=c,d=c=void 0):nulle&&("string"typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e=!1)e=ha;else if(!e)return a;return 1=f&&(g=e,e=function(a){return n().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=n.guid++)),a.each(function(){n.event.add(this,b,e,d,c)})}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=N.get(a);if®{c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return"undefined"!=typeof n&&n.event.triggered!b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(G)||[""],j=b.length;while(j--)h=fa.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!!1||a.addEventListener&&a.addEventListener(o,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=N.hasData(a)&&N.get(a);if(r&&(i=r.events)){b=(b||"").match(G)||[""],j=b.length;while(j--)if(h=fa.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|.)"+p.join(".(?:..|)")+"(.|KaTeX parse error: Expected 'EOF', got '&' at position 37: ...e(f--)k=m[f],!e&̲&q!==k.origType.../g;function pa(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function qa(a){return a.type=(null!a.getAttribute("type"))+"/"+a.type,a}function ra(a){var b=na.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function sa(a,b){var c,d,e,f,g,h,i,j;if(1=b.nodeType){if(N.hasData(a)&&(f=N.access(a),g=N.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}O.hasData(a)&&(h=O.access(a),i=n.extend({},h),O.set(b,i))}}function ta(a,b){var c=b.nodeName.toLowerCase();"input"===c&&X.test(a.type)?b.checked=a.checked:"input"!c&&"textarea"!c||(b.defaultValue=a.defaultValue)}function ua(a,b,c,d){b=f.apply([],b);var e,g,h,i,j,k,m=0,o=a.length,p=o-1,q=b[0],r=n.isFunction(q);if(r||o>1&&"string"typeof q&&!l.checkClone&&ma.test(q))return a.each(function(e){var f=a.eq(e);r&&(b[0]=q.call(this,e,f.html())),ua(f,b,c,d)});if(o&&(e=ca(b,a[0].ownerDocument,!1,a,d),g=e.firstChild,1=e.childNodes.length&&(e=g),g||d)){for(h=n.map((e,"script"),qa),i=h.length;o>m;m++)j=e,m!==p&&(j=n.clone(j,!0,!0),i&&n.merge(h,* (j,"script"))),c.call(a[m],j,m);if(i)for(k=h[h.length-1].ownerDocument,n.map(h,ra),m=0;i>m;m++)j=h[m],Z.test(j.type||"")&&!N.access(j,"globalEval")&&n.contains(k,j)&&(j.src?n.evalUrl&&n.evalUrl(j.src):n.globalEval(j.textContent.replace(oa,"")))}return a}function va(a,b,c){for(var d,e=b?n.filter(b,a):a,f=0;null!=(d=e[f]);f++)c||1!==d.nodeType||n.cleanData((d)),d.parentNode&&(c&&n.contains(d.ownerDocument,d)&&aa( (d,"script")),d.parentNode.removeChild(d));return a}n.extend({htmlPrefilter:function(a){return a.replace(ka,"<1\>\")}̲,clone:function...\[(Y.exec(a)\|\|\["",""\])\[1\].toLowerCase()\]){a=n.htmlPrefilter(a);try{for(;d\>c;c++)b=this\[c\]\|\|{},1=b.nodeType\&\&(n.cleanData(*(b,!1)),b.innerHTML=a);b=0}catch(e){}}b\&\&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=\[\];return ua(this,arguments,function(b){var c=this.parentNode;n.inArray(this,a)\<0\&\&(n.cleanData(*(this)),c\&\&c.replaceChild(b,this))},a)}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn\[a\]=function(a){for(var c,d=\[\],e=n(a),f=e.length-1,h=0;f\>=h;h++)c=h=f?this:this.clone(!0),n(e\[h\])[b](c),g.apply(d,c.get());return this.pushStack(d)}});var wa,xa={HTML:"block",BODY:"block"};function ya(a,b){var c=n(b.createElement(a)).appendTo(b.body),d=n.css(c\[0\],"display");return c.detach(),d}function za(a){var b=d,c=xa\[a\];return c\|\|(c=ya(a,b),"none"!==c\&\&c\|\|(wa=(wa\|\|n("")).appendTo(b.documentElement),b=wa\[0\].contentDocument,b.write(),b.close(),c=ya(a,b),wa.detach()),xa\[a\]=c),c}var Aa=/\^margin/,Ba=new RegExp("\^("+S+")(?!px)\[a-z%\]+KaTeX parse error: Expected '}', got '\&' at position 65: ...ltView;return c\&̲\&c.opener\|\|(c=a.../,Va=/queueHooks/;function Wa(){return a.setTimeout(function(){Sa=void 0}),Sa=n.now()}function Xa(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=U[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ya(a,b,c){for(var d,e=(_a.tweeners[b]||[]).concat(_a.tweeners[""]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Za(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},o=a.style,p=a.nodeType&&V(a),q=N.get(a,"fxshow");c.queue||(h=n._queueHooks(a,"fx"),nullh.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,n.queue(a,"fx").length||h.empty.fire()})})),1=a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=n.css(a,"display"),k="none"=j?N.get(a,"olddisplay")||za(a.nodeName):j,"inline"=k&&"none"=n.css(a,"float")&&(o.display="inline-block")),c.overflow&&(o.overflow="hidden",l.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Ua.exec(e)){if(delete b[d],f=f||"toggle"=e,e=(p?"hide":"show")){if("show"!e||!q||void 0=q[d])continue;p=!0}m[d]=q&&q[d]||n.style(a,d)}else j=void 0;if(n.isEmptyObject(m))"inline"=("none"=j?za(a.nodeName):j)&&(o.display=j);else{q?"hidden"in q&&(p=q.hidden):q=N.access(a,"fxshow",{}),f&&(q.hidden=!p),p?n(a).show():l.done(function(){n(a).hide()}),l.done(function(){var b;N.remove(a,"fxshow");for(b in m)n.style(a,b,m[b])});for(d in m)g=Ya(p?q[d]:0,d,l),d in q||(q[d]=g.start,p&&(g.end=g.start,g.start="width"=d||"height"=d?1:0))}}function KaTeX parse error: Expected '}', got '&' at position 79: ...c],n.isArray(f)&̲&(e=f[1],f=a[c]...a(k,j.opts.specialEasing);g>f;f++)if(d=_a.prefilters[f].call(j,a,k,j.opts))return n.isFunction(d.stop)&&(n._queueHooks(j.elem,j.opts.queue).stop=n.proxy(d.stop,d)),d;return n.map(k,Ya,j),n.isFunction(j.opts.start)&&j.opts.start.call(a,j),n.fx.timer(n.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}n.Animation=n.extend(_a,{tweeners:{"":[function(a,b){var c=this.createTween(a,b);return W(c.elem,a,T.exec(b),c),c}]},tweener:function(a,b){n.isFunction(a)?(b=a,a=["* "]):a=a.match(G);for(var c,d=0,e=a.length;e>d;d++)c=a[d],_a.tweeners[c]=_a.tweeners[c]||[],_a.tweeners[c].unshift(b)},prefilters:[Za],prefilter:function(a,b){b?_a.prefilters.unshift(a):_a.prefilters.push(a)}}),n.speed=function(a,b,c){var d=a&&"object"typeof a?n.extend({},a):{complete:c||!c&&b||n.isFunction(a)&&a,duration:a,easing:c&&b||b&&!n.isFunction(b)&&b};return d.duration=n.fx.off?0:"number"typeof d.duration?d.duration:d.duration in n.fx.speeds?n.fx.speeds[d.duration]:n.fx.speeds._default,null!=d.queue&&d.queue!!0||(d.queue="fx"),d.old=d.complete,d.complete=function(){n.isFunction(d.old)&&d.old.call(this),d.queue&&n.dequeue(this,d.queue)},d},n.fn.extend({fadeTo:function(a,b,c,d){return this.filter(V).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=n.isEmptyObject(a),f=n.speed(b,c,d),g=function(){var b=_a(this,n.extend({},a),f);(e||N.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue=!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b©};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=n.timers,g=N.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Va.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!this||null!=a&&f[e].queue!a||(f[e].anim.stop©,b=!1,f.splice(e,1));!b&&c||n.dequeue(this,a)})},finish:function(a){return a!!1&&(a=a||"fx"),this.each(function(){var b,c=N.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=n.timers,g=d?d.length:0;for(c.finish=!0,n.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem=this&&f[b].queue=a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),n.each(["toggle","show","hide"],function(a,b){var c=n.fn[b];n.fn[b]=function(a,d,e){return nulla||"boolean"typeof a?c.apply(this,arguments):this.animate(Xa(b,!0),a,d,e)}}),n.each({slideDown:Xa("show"),slideUp:Xa("hide"),slideToggle:Xa("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){n.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),n.timers=[],n.fx.tick=function(){var a,b=0,c=n.timers;for(Sa=n.now();b<c.length;b++)a=c[b],a()||c[b]!a||c.splice(b--,1);c.length||n.fx.stop(),Sa=void 0},n.fx.timer=function(a){n.timers.push(a),a()?n.fx.start():n.timers.pop()},n.fx.interval=13,n.fx.start=function(){Ta||(Ta=a.setInterval(n.fx.tick,n.fx.interval))},n.fx.stop=function(){a.clearInterval(Ta),Ta=null},n.fx.speeds={slow:600,fast:200,_default:400},n.fn.delay=function(b,c){return b=n.fx?n.fx.speeds[b]||b:b,c=c||"fx",this.queue(c,function(c,d){var e=a.setTimeout(c,b);d.stop=function(){a.clearTimeout(e)}})},function(){var a=d.createElement("input"),b=d.createElement("select"),c=b.appendChild(d.createElement("option"));a.type="checkbox",l.checkOn=""!a.value,l.optSelected=c.selected,b.disabled=!0,l.optDisabled=!c.disabled,a=d.createElement("input"),a.value="t",a.type="radio",l.radioValue="t"=a.value}();var ab,bb=n.expr.attrHandle;n.fn.extend({attr:function(a,b){return K(this,n.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){n.removeAttr(this,a)})}}),n.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!f&&8!f&&2!f)return"undefined"typeof a.getAttribute?n.prop(a,b,c):(1=f&&n.isXMLDoc(a)||(b=b.toLowerCase(),e=n.attrHooks[b]||(n.expr.match.bool.test(b)?ab:void 0)),void 0!c?null=c?void n.removeAttr(a,b):e&&"set"in e&&void 0!(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!(d=e.get(a,b))?d:(d=n.find.attr(a,b),nulld?void 0:d))},attrHooks:{type:{set:function(a,b){if(!l.radioValue&&"radio"=b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(G);if(f&&1=a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test©&&(a[d]=!1),a.removeAttribute©}}),ab={set:function(a,b,c){return b=!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/w+/g),function(a,b){var c=bb[b]||n.find.attr;bb[b]=function(a,b,d){var e,f;return d||(f=bb[b],bb[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,bb[b]=f),e}});var cb=/^(?:input|select|textarea|button) / i , d b = / ( ? : a ∣ a r e a ) /i,db=/^(?:a|area) /i,db=/(?:a∣area)/i;n.fn.extend({prop:function(a,b){return K(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!f&&8!f&&2!f)return 1=f&&n.isXMLDoc(a)||(b=n.propFix[b]||b,
e=n.propHooks[b]),void 0!c?e&&"set"in e&&void 0!(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=n.find.attr(a,"tabindex");return b?parseInt(b,10):cb.test(a.nodeName)||db.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),l.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var eb=/[
]/g;function fb(a){return a.getAttribute&&a.getAttribute("class")||""}n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,fb(this)))});if("string"typeof a&&a){b=a.match(G)||[];while(c=this[i++])if(e=fb©,d=1=c.nodeType&&(" "+e+" ").replace(eb," ")){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=n.trim(d),e!h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,fb(this)))});if(!arguments.length)return this.attr("class","");if("string"typeof a&&a){b=a.match(G)||[];while(c=this[i++])if(e=fb©,d=1=c.nodeType&&(" "+e+" ").replace(eb," ")){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=n.trim(d),e!h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"typeof b&&"string"=c?b?this.addClass(a):this.removeClass(a):n.isFunction(a)?this.each(function©{n(this).toggleClass(a.call(this,c,fb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"=c){d=0,e=n(this),f=a.match(G)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!a&&"boolean"!c||(b=fb(this),b&&N.set(this,"className",b),this.setAttribute&&this.setAttribute("class",b||a=!1?"":N.get(this,"className")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1=c.nodeType&&(" "+fb©+" ").replace(eb," ").indexOf(b)>-1)return!0;return!1}});var gb=/
/g,hb=/[
]+/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function©{var e;1=this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,nulle?e="":"number"typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return nulla?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!(c=b.get(e,"value"))?c:(c=e.value,"string"typeof c?c.replace(gb,""):nullc?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a)).replace(hb," ")}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"=a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],(c.selected||i=e)&&(l.optDisabled?!c.disabled:null=c.getAttribute("disabled"))&&(!c.parentNode.disabled||!n.nodeName(c.parentNode,"optgroup"))){if(b=n©.val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(n.valHooks.option.get(d),f)>-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>-1:void 0}},l.checkOn||(n.valHooks[this].get=function(a){return null=a.getAttribute("value")?"on":a.value})});var ib=/^(?:focusinfocus|focusoutblur)KaTeX parse error: Expected '}', got '&' at position 180: ...,3!==e.nodeType&̲&8!==e.nodeType...)"):null,b.result=void 0,b.target||(b.target=e),c=nullc?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},f||!o.trigger||o.trigger.apply(e,c)!!1)){if(!f&&!o.noBubble&&!n.isWindow(e)){for(j=o.delegateType||q,ib.test(j+q)||(h=h.parentNode);h;h=h.parentNode)p.push(h),i=h;i=(e.ownerDocument||d)&&p.push(i.defaultView||i.parentWindow||a)}g=0;while((h=p[g++])&&!b.isPropagationStopped())b.type=g>1?j:o.bindType||q,m=(N.get(h,"events")||{})[b.type]&&N.get(h,"handle"),m&&m.apply(h,c),m=l&&h[l],m&&m.apply&&L(h)&&(b.result=m.apply(h,c),b.result=!1&&b.preventDefault());return b.type=q,f||b.isDefaultPrevented()||o._default&&o.default.apply(p.pop(),c)!!1||!L(e)||l&&n.isFunction(e[q])&&!n.isWindow(e)&&(i=e[l],i&&(e[l]=null),n.event.triggered=q,eq,n.event.triggered=void 0,i&&(e[l]=i)),b.result}},simulate:function(a,b,c){var d=n.extend(new n.Event,c,{type:a,isSimulated:!0});n.event.trigger(d,null,b),d.isDefaultPrevented()&&c.preventDefault()}}),n.fn.extend({trigger:function(a,b){return this.each(function(){n.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?n.event.trigger(a,b,c,!0):void 0}}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){n.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),n.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),l.focusin="onfocusin"in a,l.focusin||n.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){n.event.simulate(b,a.target,n.event.fix(a))};n.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=N.access(d,b);e||d.addEventListener(a,c,!0),N.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=N.access(d,b)-1;e?N.access(d,b,e):(d.removeEventListener(a,c,!0),N.remove(d,b))}}});var jb=a.location,kb=n.now(),lb=/?/;n.parseJSON=function(a){return JSON.parse(a+"")},n.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||n.error("Invalid XML: "+b),c};var mb=/#.*KaTeX parse error: Expected 'EOF', got '&' at position 10: /,nb=/([?&̲])=[^&]*/,ob=/.../gm,pb=/^(?:about|app|app-storage|.±extension|file|res|widget)😒/,qb=/^(?:GET|HEAD)/,rb=/^///,sb={},tb={},ub="* /".concat("*"),vb=d.createElement("a");vb.href=jb.href;function wb(a){return function(b,c){"string"!=typeof b\&\&(c=b,b="* ");var d,e=0,f=b.toLowerCase().match(G)\|\|\[\];if(n.isFunction©)while(d=f\[e++\])"+"=d\[0\]?(d=d.slice(1)\|\|"\*",(a\[d\]=a\[d\]\|\|\[\]).unshift©):(a\[d\]=a\[d\]\|\|\[\]).push©}}function xb(a,b,c,d){var e={},f=a=tb;function g(h){var i;return e\[h\]=!0,n.each(a\[h\]\|\|\[\],function(a,h){var j=h(b,c,d);return"string"!=typeof j\|\|f\|\|e\[j\]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes\[0\])\|\|!e\["*"\]\&\&g("* ")}function yb(a,b){var c,d,e=n.ajaxSettings.flatOptions\|\|{};for(c in b)void 0!b\[c\]\&\&((e\[c\]?a:d\|\|(d={}))\[c\]=b\[c\]);return d\&\&n.extend(!0,a,d),a}function zb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"=i\[0\])i.shift(),void 0=d\&\&(d=a.mimeType\|\|b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h\[e\]\&\&h\[e\].test(d)){i.unshift(e);break}if(i\[0\]in c)f=i\[0\];else{for(e in c){if(!i\[0\]\|\|a.converters\[e+" "+i\[0\]\]){f=e;break}g\|\|(g=e)}f=f\|\|g}return f?(f!==i\[0\]\&\&i.unshift(f),c\[f\]):void 0}function Ab(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k\[1\])for(g in a.converters)j\[g.toLowerCase()\]=a.converters\[g\];f=k.shift();while(f)if(a.responseFields\[f\]\&\&(c\[a.responseFields\[f\]\]=b),!i\&\&d\&\&a.dataFilter\&\&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("* "=f)f=i;else if("*"!==i\&\&i!==f){if(g=j\[i+" "+f\]\|\|j\["* "+f\],!g)for(e in j)if(h=e.split(" "),h\[1\]=f\&\&(g=j\[i+" "+h\[0\]\]\|\|j\["\* "+h\[0\]\])){g=!0?g=j\[e\]:j\[e\]!!0\&\&(f=h\[0\],k.unshift(h\[1\]));break}if(g!!0)if(g\&\&a\["throws"\])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}n.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:jb.href,type:"GET",isLocal:pb.test(jb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":ub,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":n.parseJSON,"text xml":n.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?yb(yb(a,n.ajaxSettings),b):yb(n.ajaxSettings,a)},ajaxPrefilter:wb(sb),ajaxTransport:wb(tb),ajax:function(b,c){"object"typeof b\&\&(c=b,b=void 0),c=c\|\|{};var e,f,g,h,i,j,k,l,m=n.ajaxSetup({},c),o=m.context\|\|m,p=m.context\&\&(o.nodeType\|\|o.jquery)?n(o):n.event,q=n.Deferred(),r=n.Callbacks("once memory"),s=m.statusCode\|\|{},t={},u={},v=0,w="canceled",x={readyState:0,getResponseHeader:function(a){var b;if(2=v){if(!h){h={};while(b=ob.exec(g))h\[b\[1\].toLowerCase()\]=b\[2\]}b=h\[a.toLowerCase()\]}return nullb?null:b},getAllResponseHeaders:function(){return 2=v?g:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return v\|\|(a=u\[c\]=u\[c\]\|\|a,t\[a\]=b),this},overrideMimeType:function(a){return v\|\|(m.mimeType=a),this},statusCode:function(a){var b;if(a)if(2\>v)for(b in a)s\[b\]=\[s\[b\],a\[b\]\];else x.always(a\[x.status\]);return this},abort:function(a){var b=a\|\|w;return e\&\&e.abort(b),z(0,b),this}};if(q.promise(x).complete=r.add,x.success=x.done,x.error=x.fail,m.url=((b\|\|m.url\|\|jb.href)+"").replace(mb,"").replace(rb,jb.protocol+"//"),m.type=c.method\|\|c.type\|\|m.method\|\|m.type,m.dataTypes=n.trim(m.dataType\|\|"\*").toLowerCase().match(G)\|\|\[""\],nullm.crossDomain){j=d.createElement("a");try{j.href=m.url,j.href=j.href,m.crossDomain=vb.protocol+"//"+vb.host!=j.protocol+"//"+j.host}catch(y){m.crossDomain=!0}}if(m.data\&\&m.processData\&\&"string"!=typeof m.data\&\&(m.data=n.param(m.data,m.traditional)),xb(sb,m,c,x),2=v)return x;k=n.event\&\&m.global,k\&\&0=n.active++\&\&n.event.trigger("ajaxStart"),m.type=m.type.toUpperCase(),m.hasContent=!qb.test(m.type),f=m.url,m.hasContent\|\|(m.data\&\&(f=m.url+=(lb.test(f)?"\&":"?")+m.data,delete m.data),m.cache=!1\&\&(m.url=nb.test(f)?f.replace(nb,"KaTeX parse error: Expected 'EOF', got '\&' at position 27: ...f+(lb.test(f)?"\&̲":"?")+"_="+kb+.../,Db=/
?
/g,Eb=/\^(?:submit\|button\|image\|reset\|file)KaTeX parse error: Expected '}', got '\&' at position 159: ...ject"==typeof e\&̲\&null!=e?b:"")+...)\|??/;n.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Jb.pop()\|\|n.expando+"_"+kb++;return this\[a\]=!0,a}}),n.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!!1\&\&(Kb.test(b.url)?"url":"string"typeof b.data\&\&0=(b.contentType\|\|"").indexOf("application/x-www-form-urlencoded")\&\&Kb.test(b.data)\&\&"data");return h\|\|"jsonp"=b.dataTypes\[0\]?(e=b.jsonpCallback=n.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b\[h\]=b\[h\].replace(Kb,"KaTeX parse error: Expected 'EOF', got '\&' at position 19: ...e):b.jsonp!==!1\&̲\&(b.url+=(lb.te...;return n.noConflict=function(b){return a.KaTeX parse error: Expected 'EOF', got '\&' at position 5: ===n\&̲\&(a.=Ob),b\&\&a.jQuery=n\&\&(a.jQuery=Nb),n},b\|\|(a.jQuery=a.=n),n});
2.在全局配置文件中添加文件上传的相关配置
#设置单个文件上传的大小限制
spring.servlet.multipart.max-file-size=10MB
#用来设置所有上传文件的大小限制
spring.servlet.multipart.max-request-size=50MB
#如果上传文件的大小超过啦限制,就会报错
3.进行文件上传处理,实现文件上传功能
package com.waiguoyu.day5.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.UUID;
/**
* 这个类用于实现文件上传功能,管理文件上传下载的。
*/
@Controller
public class FiletControllet {
//向文件上传页面跳转,这个类用于处理/toUpload的get请求
@GetMapping("/toUpload")
public String toUpload() {
return "upload";
}
//用于处理/uploadFile路径的post请求,文件上传成功,文件存储在E:/file/,上传失败就会提示相关信息
// 注意:方法的参数ultipartFile[] fileUpload名称要与上传页面的input的name相同,具体在哪里看我的截图
@PostMapping("/uploadFile")
public String uploadFile(MultipartFile[] fileUpload, Model model) {
// 默认文件上传成功,并返回状态信息
model.addAttribute("uploadStatus", "上传成功!");
for (MultipartFile file : fileUpload) {
// 获取文件名以及后缀名
String fileName = file.getOriginalFilename();
// 重新生成文件名(根据具体情况生成对应文件名)
fileName = UUID.randomUUID()+"_"+fileName;
// 指定上传文件本地存储目录,不存在需要提前创建
String dirPath = "E:/file/";
File filePath = new File(dirPath);
if(!filePath.exists()){
filePath.mkdirs();
}
try {
file.transferTo(new File(dirPath+fileName));
} catch (Exception e) {
e.printStackTrace();
// 上传失败,返回失败信息
model.addAttribute("uploadStatus","上传失败: "+e.getMessage());
}
}
// 携带上传状态信息回调到文件上传页面
return "upload";
}
}
我们访问:http://localhost:8080/toUpload
这样就可以访问到相关页面进行上传啦,并且我们可以多次点击上传文件,就可以进行多个文件的上传了。
5.2.3 文件下载
下载文件通过io流实现,很多框架没有对这个功能进行封装处理,文件下载设计不同浏览器的解析处理,所以会有乱码的问题。下面我们对不同语言的文件进行讲解:
1.英文名文件下载
1.添加文件下载工具依赖:
映入相关依赖:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
2.定制文件下载页面
我们创建一个演示文件下载的页面:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>文件下载</title>
</head>
<body>
<div style="margin-bottom: 10px">文件下载列表:</div>
<table>
<tr>
<td>bloglogo.jpg</td>
<td><a th:href="@{/download(filename='bloglogo.jpg')}">下载文件</a></td>
</tr>
<tr>
<td>Spring Boot应用级开发教程.pdf</td>
<td><a th:href="@{/download(filename='Spring Boot应用级开发教程.pdf')}">
下载文件</a></td>
</tr>
</table>
</body>
</html>
这里通过列表的方式展示要下载的文件的相关信息,注意:在文件下载连接处,本地对应的地址要有对应的文件才可以,这里可以自行存放文件。这里只是指定要下载的文件名。
3.在之前的文件管理控制类编写文件下载处理方法:
// 向文件下载页面跳转
@GetMapping("/toDownload")
public String toDownload(){
return "download";
}
// 文件下载管理,下载的数据类型:ResponseEntity<byte[]>;
@GetMapping("/download")//处理/downloa的get请求
public ResponseEntity<byte[]> fileDownload(String filename){
// 指定要下载的文件根路径
String dirPath = "E:/file/";
// 创建该文件对象
File file = new File(dirPath + File.separator + filename);
// 设置响应头
HttpHeaders headers = new HttpHeaders();
// 通知浏览器以下载方式打开
headers.setContentDispositionFormData("attachment",filename);
// 定义以流的形式下载返回文件数据
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
try {
return new ResponseEntity<>(FileUtils.readFileToByteArray(file), headers, HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<byte[]>(e.getMessage().getBytes(),HttpStatus.EXPECTATION_FAILED);
}
}
在这里设置具体的下载的路径以及其他的信息。
运行:下载测试
需要注意的是在页面的文件名要与所在路径下的文件的文件名相同才可以。这里设置啦下载英文文件名的文件,大家可以用英文文件名的文件进行测试。
2.中文文件名文件下载
使用上面方法下载的中文名文件,下载到本地的文件名不理想。
要进行额外的处理才可以:
在上边文件管理类的fileDownload()中修改代码:
// 文件下载管理,下载的数据类型:ResponseEntity<byte[]>;
@GetMapping("/download")//处理/downloa的get请求
public ResponseEntity<byte[]> fileDownload(HttpServletRequest request, String filename) throws IOException {
// 指定要下载的文件根路径
String dirPath = "E:/file/";
// 创建该文件对象
File file = new File(dirPath + File.separator + filename);
// 设置响应头
HttpHeaders headers = new HttpHeaders();
//在下载前对文件名进行转码
filename= getFilename(request,filename);
// 通知浏览器以下载方式打开
headers.setContentDispositionFormData("attachment",filename);
// 定义以流的形式下载返回文件数据
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
try {
return new ResponseEntity<>(FileUtils.readFileToByteArray(file), headers, HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<byte[]>(e.getMessage().getBytes(),HttpStatus.EXPECTATION_FAILED);
}
}
//根据浏览器的不同进行编码设置,返回编码后的文件名.也就是对不同的浏览器下载的中文名进行编码
private String getFilename(HttpServletRequest request, String filename) throws IOException {
//IE不同版本User-Agent中出现的关键词
String[] IEBrowserKeyWords = {"MSIE","Trident","Firefox","Opera","Chrome","Edge"};
//获取请求头代理信息,request.getHeader("User-Agent");获取用户下载文件的浏览器内核信息
String userAgent = request.getHeader("User-Agent");
for (String keyWord : IEBrowserKeyWords) {
// //如果浏览器内核为IE则转码为utf-8,
if (userAgent.contains(keyWord)) {
//ie内核浏览器,统一为UTF-8编码显示,并对转换的+进行更正
return URLEncoder.encode(filename, "UTF-8").replace("+", "");
}
}
//火狐等其他浏览器统一为IOS-8859-1编码
return new String(filename.getBytes("UTF-8"), "iso-8859-1");
}
最后下载的效果:
5.4springboot应用的打包和部署
传统的web应用使用war包的形式进行打包和部署,而springboot默认使用jar包形式进行打包和部署的。下面分别讲解jar包形式和war包形式的打包和部署方法
5.4.1 jar包方式打包部署
打包方式:
<build>
<plugins>
<!-- maven打包插件-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
打开maven操作界面,点击package进行打包。
控制台有这个代表项目打包成功啦。并且控制台会给出对应包所在的位置。
打开对应的jar包:
使用压缩软件打开:
部署:
bug : 在这里我出现问题啦,总是部署不成功。
5.4.2war包方式打包部署
springboot内嵌的tomcat可以直接将项目打成jar包进行部署,有时候还需要外部的tomcat进行i项目管理,就需要把i项目打包成war包,
war包打包方式:
1.在pom文件里声明打包方式为war包。
<!-- 将打包方式改为war-->
<packaging>war</packaging>
2.在pom文件声明使用外部tomcat服务器
<!-- <artifactId>spring-boot-starter-tomcat</artifactId>指定啦内部的tomcat服务器,<scope>provided</scope>将服务器声明为外部已提供provided-->
<!-- 这样就可以对两种打包方式进行部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
3.提供springboot启动的servlet初始化器。最重要的就是这一步:
在主程序启动类中进行这样操作:
@SpringBootApplication
@ServletComponentScan
/*
继承SpringBootServletInitializer类
* */
public class Day5Application extends SpringBootServletInitializer {
// 重写configure方法。
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// .sources方法第一个参数必须是主程序启动类,
return builder.sources(Day5Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Day5Application.class, args);
}
}
完成以上3步就可以进行打包啦。
打包的方式和上边的一样。
war包部署方式:这里我就截图啦,只需要跟着步骤走就可以啦
小结
读者要充分掌握springboot进行web开发中主要功能的配置和扩展,能够完成实际开发中springboot项目的开发和部署工作。
再看看本章目标是否达成啦: