关于在springboot和thyemleaf模板中开发遇到的问题总结-----《毕设第二稿》

springboot邮件发送以及thyemleaf生成邮件模板 邮件常见的三大协议:SMTP、POP3、IMAP SMTP 是一个基于 TCP/IP 的应用层协议,江湖地位有点类似于 HTTP,SMTP 服务器默认监听的端口号为 25 。由于SMTP 协议是基于 TCP/IP 的应用层协议,我们可以通过 Socket 发送一封邮件。 SMTP 协议全称为 Simple Mail Transfer Protocol,译作简单邮件传输协议,它定义了邮件客户端软件与 SMTP 服务器之间,以及 SMTP 服务器与 SMTP 服务器之间的通信规则。 阅读详情

问题1 :Error resolving template [xxx], template might not exist or might not be accessible by any of the configured Template Resolvers

解决方案: 这个问题出现的原因是什么呢,从翻译来说,这个就是解析不了template模板,在我们return的时候,因为springboot的配置静态资源默认在 static下,读取的模板在template下,如果不将thyemleaf渲染的模板放到template下,那么 就会报这个错误,
.yml 配置如下:

在这里插入图片描述

thymeleaf:
    prefix: classpath:/templates/
    suffix: .html
    mode: HTML
    encoding: UTF-8
    cache: false
    servlet:
      content-type: text/html

问题2 :springboot如何设置未登录不能跳转到其他页面只能跳转 到登陆页面

解决方案: 用到 springmvc 的拦截器,自定义拦截路径:
配置是这样的:
在这里插入图片描述
代码附上:

package com.config;

import com.incerceptor.LoginInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class MvcConfig implements WebMvcConfigurer {
    /**
     * 通过@Bean注解,将我们定义的拦截器注册到Spring容器
     * @return
     */
    @Bean
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }

    /**
    * 可以将不需要拦截的路径 ,比如说静态资源的路径放行,将下面的路劲添加到拦截器的后缀即可
    * */

    String[] excludePathPatterns = {
            "/user/login","/user/error","/user/out"
    };
    /**
     * 重写接口中的addInterceptors方法,添加自定义拦截器
     * @param registry
     */

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
// 通过registry来注册拦截器,通过addPathPatterns来添加拦截路径
        registry.addInterceptor(this.loginInterceptor()).addPathPatterns("/admin/**").addPathPatterns("/teacher/**");
    }


}

package com.incerceptor;
import com.pojo.admin;
import com.pojo.teacher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class LoginInterceptor implements HandlerInterceptor {
    private Logger logger = LoggerFactory.getLogger(LoginInterceptor.class);
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
        logger.debug("处理器执行前执行!");
        String basePath = request.getContextPath();//输出为空 其实就是输出端口号之前的url
        /*
        * 在后端重定向页面的时候可以这样用
        * response.sendRedirect(request.getContextPath()+"/IndexServlet");
        * */
        String path = request.getRequestURI();//输出为去掉端口号后的URL
        System.out.println(path);
        //获取登录对象的账号密码存入session
        admin a=(admin)request.getSession().getAttribute("admin");
        teacher t= (teacher) request.getSession().getAttribute("teacher");
        //根据不同的请求让他跳转到不同的路径
        if(path.startsWith("/admin")){
            if (a==null){
                //此处 加.html 原因是因为  登录页面不在默认的template下,在static下
               // response.sendRedirect("/AdminLogin.html");
                response.sendRedirect("/AdminLogin.html");
                return false;
            }
        }
        else if (path.startsWith("/teacher")){
            if (t==null){
                response.sendRedirect("/TeacherLogin.html");
                return false;
            }
        }
        else{
          return false;
        }

        return true;
    }
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object
            handler, ModelAndView modelAndView) {
        logger.debug("处理器执行后执行!");
    }
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object
            handler, Exception ex) {
        logger.debug("跳转后执行!");
    }
}


问题3 :springboot 启动如何访问到templates下的html页面

解决方案: springboot 启动默认访问的是static下的 index页面,如果登录页面写到了template下 我们就需要根据请求 去到达那个页面 :案例如下:

 @RequestMapping("/Alogin")
   public String loginPage(){
       //这里不用这种方法的原因是因为把 该页面从static移到了templates目录下
       //return "redirect:AdminLogin.html";
       return  "AdminLogin";
   }

问题4 :如何让springboot项目不同页面只需要登录一次-----用session来解决这个问题

解决方案: 现在上线的网站的登录功能都是这样的,只需要一次登录,那么在打开新窗口的时候 再次访问别的页面的时候,被拦截器拦截下来,因为我们登录时的 账户是“无状态的”,现在要让他有状态,那就把登录信息存储到session里面,操作如下:

  /*
   * 可以用两种方法来获取前端输入的账号密码
   * 1  写一个对象 包含账号密码,然后读取数据
   * 2 用servlet来获取
   * 3 用下面这种方式,参数名和传来的 name 名相同就行
   * */
   @RequestMapping(value = "/login" ,method = RequestMethod.POST)
   public String login(int id, String pass,Model model, HttpServletRequest request, HttpServletResponse response) throws InterruptedException {

       List<admin> list =adminService.list();

       for (int i = 0; i < list.size() ; i++) {
           //先判断账号是否存在,如果存在在进一步判断密码
          if (id== list.get(i).getId()){
              //判断密码是否正确
              if (pass.equals(list.get(i).getPassword())) {
                  admin admin=new admin();
                  admin=adminService.getById(id);
                  // 将登录信息存到session里边,这样在登录的情况下是可以访问其他页面的
                 //  request.getSession().setAttribute("admin",admin);
                  HttpSession session=request.getSession();
                  session.setAttribute("admin",admin);
                  //设置session的超时时间 此处为半小时
                  session.setMaxInactiveInterval(30*60);
                  model.addAttribute("admin",admin);
                  return "adminIndex";
              }
              //密码不正确  则弹出框提示
              else {
                 model.addAttribute("msg", "密码错误");
                  return  "AdminLogin";
              }
          }
          else {
              model.addAttribute("msg", "账号不存在");
              //这里不用这种方法的原因是因为把 该页面从static移到了templates目录下
              //return "redirect:AdminLogin.html";
              return  "AdminLogin";
          }


       }
       /*这里返回不带后缀的请求只针对thyemleaf,因为这个模板不在template下,所以用重定向
        return  "redirect:AdminLogin.html";
       */
       return "AdminLogin";
   }

在这里插入图片描述
在上边的拦截器里 我们已经写过了,

问题5 :如何让 用户信息到了指定的时间让session失效

解决方案:在一般系统登录后,都会设置一个当前session失效的时间,以确保在用户长时间不与服务器交互,自动退出登录,销毁session给session设置失效时间,到了指定时间 ,session过期,那么访问其他请求就会被拦截下来。

简单的方法:不在前端做判断,只在后端设置一个常规的存活时间,到期删除掉session即可
在这里插入图片描述
设计正常的 判断页面用户无操作,然后向后端发送请求,删除session后返回前端

代码:

<script>
    //浏览器长时间微操作,注销session ,
    var oldTime = new Date().getTime();
    var newTime = new Date().getTime();
    var outTime = 8*60*1000; //设置超时时间: 8分钟

    console.log(oldTime);
    console.log(newTime);
    $(function(){
        /* 鼠标移动事件 */
        $(document).mouseover(function(){
            oldTime = new Date().getTime(); //鼠标移入重置停留的时间
            console.log(oldTime);
        });
    });

    function OutTime(){

        newTime = new Date().getTime(); //更新未进行操作的当前时间
        if(newTime - oldTime > outTime){ //判断是否超时不操作
            console.log("时间到,退出登录");
            //发送请求到后端删除session;
            window.parent.location.replace("delSession");
        }
    }
    /* 定时器  判断每5秒是否长时间未进行页面操作 */
    window.setInterval(OutTime, 3000);
</script>
@RequestMapping("/delSession")
    public  String delSession(){
       session.removeAttribute("admin");
       return "AdminLogin";
    }

问题6 :Uncaught ReferenceError: $ is not defined

解决方案:这个问题是js文件没有成功引入,还是thyemleaf模板引入静态资源的问题,
注意引入路径的问题即可,静态资源一般还是放在static下,放在template下访问不到

在这里插入图片描述

问题7 :thyemleaf模板接收不到后端传来的msg消息

解决方案:这个问题出现的原因是因为我的static里放了 thyemleaf模板渲染的html,导致传过去的参数在static下接收不到,还有一点是 script 接收model参数是这样接收的

@RequestMapping("/parameterTest")
public String ParamTest(Model model){
    model.addAttribute("param","test" );
    return "paramTest";
}

<script th:inline="javascript">
       //方式一
        var param = [[${param}]];
       //方式二
        param = /*[[${param }]]*/""   
        console.log("param :"+ param )
    </script>

Js和Thymeleaf如何获取model中的值

问题8 :如何设置提示消息定时消失

解决方案:有时候需要做这样一个业务操作,就是账号密码输入错误的时候,弹框提醒,然后几秒后消失

<script th:inline="javascript">

    // 让提示定时消失
    setTimeout(function (){
        $ ("#div").css('display','none');
    },1000);


</script>
<div  id="div" style="text-align: center">
                 <p style=" font-size:20px ;color: red" th:text="${msg}" th:if="${not #strings.isEmpty(msg)}"></p>
             </div>

问题9 :表单验证 账号密码是否达到位数

解决方案:业务需求 ,有时候账号密码输入并不符合规则,这样发送到后端无疑是浪费服务器资源,然后我们可以在前端进行判断,代码是这样操作

<script type="text/javascript">
    //验证账号密码是否符合规则
    function checkusrn() {
        var check = false;
        var username = document.getElementById("id").value;
        if (username.length < 5) {
            document.getElementById("checktext1").innerHTML = " × 账号不要少于5位";
            check = false;
        } else {
            document.getElementById("checktext1").innerHTML = " √";
            check = true;
        }
        return check;
    }

    function checkpwd() {
        var check = false;
        var password = document.getElementById("pass").value;
        if (password.length < 6) {
            document.getElementById("checktext2").innerHTML = " ×密码 不要少于6位";
            check = false;
        } else {
            document.getElementById("checktext2").innerHTML = " √";
            check = true;
        }
        return check;
    }
    //满足上两条才能提交
    function check() {
        var check = checkusrn() && checkpwd() ;
        return check;
    }
</script>

表单验证

问题10: 为什么要用QueryWrapper?QueryWrapper的效率高吗

解决方案:

什么是QueryWrapper?
在调用service层封装好的查询方法getOne时,可以看到需要传的参数是queryWrapper。那么queryWrapper是啥呢?实现查询的对象封装操作类,讲人话就是queryWrapper封装了sql语句where后面的内容

QueryWrapper是在mp上更加高效的查询方式,大大的简化了我们编写SQL语句,提高我们的工作效率。

QueryWrapper快速上手

mp方法快速上手

深入解析AUTOSAR中IIC的MCAL实现与Vector配置实践 本文深入解析AUTOSAR架构中IIC总线的MCAL实现与Vector配置实践,探讨IIC在汽车电子中的特殊定位及Vector的折中方案。通过Channel与Sequence设计模式、Chain特性应用及DaVinci Configurator配置步骤,提供IIC驱动的优化与安全实现方法,助力开发者高效解决车载通信问题。 阅读详情

相关推荐

WPS JS宏实战:批量调整200个Word表格格式的避坑指南(附完整代码)

本文提供了一份详尽的WPS JS宏实战指南,针对批量调整大量Word表格格式的需求。文章深入解析了如何利用JS宏自动化设置字体、行距和边框,并重点解决了常见的“首行访问报错”等核心难题,附有可直接使用的完整代码,帮助用户显著提升文档处理效率。

weixin_29280219的博客 429

template might not exist or might not be accessible by any of the configured Template Resolvers

文章目录想实现效果报错报错原因有x以下种第1种场景错误:未设置返回格式第2种场景错误:html未打包进去(我的就是这种错误导致的)第3种场景错误:路径名写错了(网上摘抄未验证过)第4种场景错误:在使用springboot的过程中,如果使用thymeleaf作为模板文件,则要求HTML格式必须为严格的html5格式,必须有结束标签,否则会报错。(网上摘抄未验证过)第5种场景错误:模板使用thymeleaf时pom引入不正确(网上摘抄未验证过)第6种场景错误:如果使用了视图解析器,检查视图跳转WebMvcCo.

刘大猫 1万+

Python实战:用MOOTDX库轻松抓取股票分时数据并绘制专业图表(附完整代码)

本文详细介绍了如何使用Python的MOOTDX库获取股票分时数据,并通过Pandas进行数据清洗与VWAP计算,最后利用Matplotlib绘制包含价格线、均线和成交量的专业分时图。文章提供了从环境搭建、数据获取到可视化呈现的完整代码,帮助读者快速构建本地化的股票分时数据分析工具。

weixin_29041195的博客 472

template might not exist or might not be accessible by any of the configured Template Resolvers解决方法

最近写java项目,springboot框架,碰到了这个小问题。写了一个然后用postman调用打断点看了下,到return方法为止还是没有报错的,但是后续到框架方法里就报错了;

BHSZZY的博客 3336

宜搭子表单(自定义页面全部展示)

效果:增加自定义页面添加表格组件,配置数据源变量: formUuid'表单编码'变量: pageSize10变量: currentPage1。

2301_80286061的博客 2275

OpenEuler内核编译及替换

一、内核源码下载 在gitee上下载OpenEuler内核源码 下载地址 选择需要的内核版本源码压缩包进行下载 二、内核编译 1.解压缩 将下载好的源码进行解压 tar xvf openeuler-kernel-4.19.90-2107.1.0.tar.gz 2.清理源代码树 解压后得到一个名为kernel的内核源码文件夹,进入后执行命令 make mrproper 清理过去内核编译产生的config,第一次编译时可不执行此命令 3.生成内核配置文件.config 先将将系统原配置文件拷贝过来,原

m0_56602092的博客 2万+

spring boot 启动项目 加载不到 resources 目录下的配置文件或xml文件 解决方法

在POM 文件加如下配置即可 <build> <resources> // 加载不到 java 目录下的文件 配置 <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> .

weixin_45876619的博客 3590

从USB相机标定到Aruco码精准定位:基于aruco-ros的机器人视觉实践

本文详细介绍了基于aruco-ros的机器人视觉实践,从USB相机标定到Aruco码精准定位的全流程。通过实战案例和优化技巧,展示了Aruco码在机器人导航中的高精度位姿识别能力,帮助开发者快速实现毫米级视觉定位系统。

weixin_27310417的博客 487

解决:template might not exist or might not be accessible by any of the configured Template Resolvers报错

问题描述:   Spring Boot 项目访问resources/templates下静态资源文件报500错误,如果页面显示404错误一定是你地址写错了。 报错内容: Servlet.service() for servlet [dispatcherServlet] in context with path [/test] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.Tem

weixin_53106424的博客 5万+

EMI辐射发射超标案例

EMI辐射发射超标案例

让你爱上电路设计 8502

使用Simulink进行四足机器人的非线性动力学建模与仿真

四足机器人的运动包含多个自由度(DOF),包括腿部的摆动和支撑阶段的动力学特性。由于存在接触力、摩擦以及不同地形的影响,四足机器人的动力学行为呈现出高度的非线性特征。因此,构建准确的非线性动力学模型对于研究机器人的运动学和动力学特性至关重要。定义代表机器人状态的变量,如位置、速度、角度和角速度。matlab深色版本通过本指南,我们介绍了如何基于Simulink搭建一个四足机器人的非线性动力学模型,并进行了详细分析。

xiaoheshang_123的博客 311

解决thymeleaf报错 $ is not defined

学亮编程手记 1880

基于OSEK_TP.dll封装通用,多ECU自由切换的诊断函数库

本文介绍了基于CANoe内置OSEK_TP.dll库实现通用诊断通讯的方法。通过封装CAN_TP.cin顶层脚本,实现了ECU连接管理、数据收发和多ECU切换功能。系统采用字典结构存储ECU参数,支持从配置文件读取诊断ID等配置信息,通过TpCreateConnection建立TP层连接。文章详细说明了诊断请求发送函数Uds_DiagSendRequest的实现逻辑,以及如何利用回调函数处理收发事件。该方法无需依赖诊断数据库,通过底层封装实现了灵活高效的诊断通讯方案,适用于车载诊断领域的测试需求。

蚂蚁小兵 1565

06.利用layui和springboot搭建原始项目-关于layui和Thyemleaf以及springboot整合-关于layui样式在Thyemleaf不显示

一.layui

qq_27552845的博客 894

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SpringBoot+Thyemleaf

Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。通过这种方式,Spring Boot致力于在蓬勃发展的快速应用开发领域(rapid application development)成为领导者。 特点: 1. 创建独立的Spring...

denghe4720的博客 234

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

SpringBoot+Thyemleaf开发环境正常,打jar包发到服务器就报错Template might not exist or might not ..

现象就是,我在本地开发环境是好的,正常访问某个页面,但是到了打成jar包后,部署到服务器之后,再访问那个页面,总是报错。原来,是我的返回的controller里面,在返回html的路径前面多加了一个/,就是一个斜杠。一开始还以为是Thyemleaf的语法写错了,折腾了半天,哈哈哈,必须要记录一下。例如return "/index",正式这个斜杠导致报错的,解决办法:去掉前面的/即可,即return "/index"。虽然解决了我的问题,但是,这里还是有个疑问,为啥本地这样写是不报错的呢?

会编程的蜗牛的博客 529

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

springboot thyemleaf常见错误

1.获取背景图片一定要记得加上‘’ th:background="${#servletContext.contextPath}+'/static/images/blue-snow.png'" 2.js获取项目路径 记得js要加上 <script th:inline="javascript">//一定要加th:inline="javascript" 支持行内写法 //url的全...

老王的博客 451

SpringBoot整合定时器和thyemleaf模板引擎

1.定时器--Quartz 1.1 在pom文件中引入定时器依赖 <!--引入定时依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-quartz</artifactId> </dependency>

Duhangyu_01的博客 314

springboot使用thyemleaf+layui

springboot:thyemleaf+layui使用 1. 添加thyemleaf依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> <...

zlliuh的博客 1533

解决springboot项目url路径配置失败以及mapper映射文件找不到以及thyemleaf模板输入异常的问题

## Bug1:Failed to configure a DataSource: 'url' attribute is not specified and no embedded 翻译 数据库路径配置失败:url属性未指定,且未嵌入 分析: 大意应该是找不到数据库的url路径 建议在提供者工程和消费者工程的pom.xml文件上都添加如下路径配置。避免resources里面配置异常读取不到。双重保险一下。 如下代码主要是读取模块下的src路径下的resources目录里的所有配置 包括: 加载以下.

m0_49100453的博客 1376

SpringBoot+Thyemleaf开发环境正常,打包jar发到服务器就报错Template might not exist or might not be accessible

网上查看了各种解决的思路,总结如下:1. 在controller层请求处理完了返回时,没有使用@RestController或@ResponseBody而返回了非json格式这种情况下返回的数据thymeleaf模板无法解析,直接报错,本人正式因为这个原因才报错。解决方案:可以将@Controller换成@RestController,不过需要注意有没有其他的方法返回了html页面,会导致返回的不...

LiMing_0820的博客 18万+

springboot thyemleaf的th标签生效问题

la153284的博客 266

Springboot+thyemleaf+layui的跳转方式

以跳转到登录界面为例 layui: ajax请求控制页面跳转:window.location = '/toLogin'; 跳转静态页面:window.location = '../login.html'; --静态页面要求在static目录下,否则会404 springboot:controller 跳转到templates动态页面: return "login"; 如果templates目录下未找到login.html会报错 org.thymeleaf.exceptions.Templ..

享受科技,热爱生活! 1714

SpringBoot 之 Web 使用 Thymeleaf 模板

一、简介 目前 Java Web 开发推荐使用模板引擎,不建议使用 JSP 页面 JSP缺点:本质上就是Servlet,需要后台编译,耗时,效率低 模板引擎:不需要编译,速度快 常见的模板引擎:Freemarker、Velocity、Thymeleaf 等 SpringBoot 推荐使用 Thymeleaf,且默认不支持 JSP,因为 JSP 必须要打包war包才二、使用步骤 2.1、添加 Thymeleaf 依赖 <dependency> <groupId>org.spring

小坏蛋博客 405

springboot集成thyemleaf解除严格html5格式校验问题

用springboot加thyemleaf做静态模板,静态模板对html的格式非常严格,导致很多框架的格式都用不了,解除方法: 1.在pom中添加依赖: <dependency> <groupId>net.sourceforge.nekohtml</groupId> <artifactId>ne...

由入门到精通 452

Spring boot + LayIM + t-io 使用thyemleaf模板和Shiro实现登录

前言 在上一篇博客中已经实现了单聊和群聊的功能,并且做了详细讲解。不过上次还缺少灵活性,就是当前用户信息的问题,本篇中 t-io 的部分较少。并且为了实现快速登录,thymeleaf和Shiro我也只是做了简单使用,不过就做个学习记录吧。 thymeleaf模板 网上...

chengqun0244的博客 232
上一篇: 从mybatis飞越到mybatis-plus
下一篇: 解决mybatis中字段名和属性名不一致的问题------《毕设论文第三稿》
凌晨里的无聊人
博客等级 码龄8年 2320粉丝 206原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凌晨里的无聊人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值