会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132776个问题
JAVA 全系列/第二阶段:JAVA 基础深化和提高/IO 流技术(旧) 36212楼

"""
简单总结:
1. 有时候我们想要在模版中对一些变量进行处理,那么就必须需要类似于Python中的函数一样,可以将这个值传到函数中,然后做一些操作。
在模版中,过滤器相当于是一个函数,把当前的变量传入到过滤器中,然后过滤器根据自己的功能,再返回相应的值,之后再将结果渲染到页面中。

2. 基本语法:`{{ variable|过滤器名字 }}`。使用管道符号`|`进行组合。
"""
from flask import Flask,render_template

app = Flask(__name__)

# #【1】过滤器的基本使用
# @app.route('/')
# def hello_world():
#     return render_template('index.html',postion=-1)

#【2】default过滤器的基本使用
@app.route('/')
def hello_world():
    context={
        'postion':'-1'
    }
    return render_template('index.html',**context)


if __name__ == '__main__':
    app.run(debug=True)

下面是index

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h3>过滤器的基本使用</h3>
    <p>位置的绝对值为【未使用过滤器】:{{ postion }}</p>
    <p>位置的绝对值为【使用过滤器】:{{ postion|abs }}</p>
    <hr>
    <h3>default过滤器的使用</h3>
    {# 如果取的到就取什么,如果取不到过滤器就会生效 #}
 <p>个性签名【使用过滤器】:{{ signature|default("此人很烂") }}</p>
</body>
</html>

报错:TypeError: bad operand type for abs(): 'str'如下图2019-09-08.png这个是什么意思?类型错误?没添加default时候好使,添加后就报错了。??


Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Flask之Jinja2模版 36213楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/XML 技术(旧) 36221楼

image.png

怎么把schema文件引进来的?xmlns:xs="http://www.w3.org/2001/XMLSchema",是吧这个复制到根目录后边?

视频里引入的怎么是xmlns:xsi="http://www.w3.org/2001/XMLSchema";xs后边加个i什么意思,还有引入到xml文件,xml文件还写DTD吗,视频里xml文件里还有DTD呢?加了DTD是不是已经验证成功了,引入schema是不是得把DTD的内容删除再验证啊。。。。

JAVA 全系列/第二阶段:JAVA 基础深化和提高/XML 技术(旧) 36223楼

老师,我在执行了maven insatll的命令后出现了一下错误,怎么办

[INFO] Scanning for projects...

[INFO] 

[INFO] -----------------------< com.bjsxt:01mavenDemo >------------------------

[INFO] Building 01mavenDemo 0.0.1-SNAPSHOT

[INFO] --------------------------------[ jar ]---------------------------------

[INFO] 

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ 01mavenDemo ---

[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!

[INFO] Copying 0 resource

[INFO] 

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ 01mavenDemo ---

[INFO] Changes detected - recompiling the module!

[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!

[INFO] Compiling 2 source files to D:\eclipse\01mavenDemo\target\classes

[INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR : 

[INFO] -------------------------------------------------------------

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

[INFO] 1 error

[INFO] -------------------------------------------------------------

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1.842 s

[INFO] Finished at: 2019-09-07T11:00:59+08:00

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project 01mavenDemo: Compilation failure

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

[ERROR] -> [Help 1]

[ERROR] 

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR] 

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException


JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Maven 36224楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637