想弄个论坛,结果发现FTP里边没有template 我该怎么办?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了想弄个论坛,结果发现FTP里边没有template 我该怎么办?相关的知识,希望对你有一定的参考价值。

想弄个论坛,结果发现FTP里边没有template 我该怎么办?
现在FTP里边只有db、log、web
是不是空间问题?
在线等!!!

web是网站根目录,你把网站程序(源码)上传到这个文件夹里,上传完成后在浏览器里输入你的域名,填上数据库名、数据库用户名等信息就可以了。
不懂在问,我也是做论坛的,不知道你做的是那个。追问

我想做一个论坛 但是下载的discuz模板 全是上传到template里边,FTP服务器里边没有这个文件夹,也没有有些人说的wwwroot这个文件夹 就是我图上那三个文件。现在我的ftp里边是空的,上传其他模板老是失败!可否帮我找一个论坛的模板,可以上传到web根目录下的?

追答

呵呵,直接加我秋秋1272990764

参考技术A 不是,你把论坛放在web 文件夹就可以了 db是备份,log是日志 参考技术B 看看web里面有木有,木有的话上传一份,或许哥们我可以帮你,代价是我们成为朋友追问

神马都没有哦 上传试过了,直接上传失败。

    这个代价有点大啊!!!有点大O(∩_∩)O哈哈~

追答

找空间商去吧,这是空间的问题

html/template 和 text/template区别

文章目录

前言

最近在学习go template,跟着一篇文章进行例程的学习,结果发现无论怎么调试,都没有办法复现例程的打印结果

纠结了一天后,求助同事发现了其中的端倪

text/template 是将内容都已text文本格式返回。

html/tempalte针对的是需要返回HTML内容的场景。
在模板渲染过程中会对一些有风险的内容进行转义,以此来防范跨站脚本攻击。

html/template

例程中给出的代码如下

package main

import (
	"fmt"
	// "text/template"
	"html/template"
)

func main() 

	// ******ParseFiles()方法*****
	t1 := template.New("test")
	t1, err := t1.ParseFiles("a.cnf", "b.cnf", "c.cnf")

	// ******ParseFiles()定义*****
	// t1, err := template.ParseFiles("a.cnf", "b.cnf", "c.cnf")

	if err != nil 
		panic(err)
	
	// 先注释下面这行
	//t1.Parse("")
	fmt.Println(t1.DefinedTemplates())
	fmt.Println()
	fmt.Println(t1)
	fmt.Println(t1.Lookup("a.cnf"))
	fmt.Println(t1.Lookup("b.cnf"))
	fmt.Println(t1.Lookup("c.cnf"))


理论打印结果应该是:

但是可以看到我们跑程序后打印结果如下:

出现了很大的不一致,这时,我百思不得起解,无论怎么样单步调试,修改输出,都没有办法得到例程输出

最后在同事的提醒下,查看函数的源码,直接F12

首先是Template.New()

// New allocates a new HTML template with the given name.
func New(name string) *Template 
	ns := &nameSpaceset: make(map[string]*Template)
	ns.esc = makeEscaper(ns)
	tmpl := &Template
		nil,
		template.New(name),
		nil,
		ns,
	
	tmpl.set[name] = tmpl
	return tmpl

New返回tmpl,tmpl结构体中我们可以改变的是name,也就是存储我们输入的“test”

这里暂时看不出来端倪,继续看后面的t1.DefinedTemplates(),可以发现也正常,这块输出确实也是对的

func (t *Template) DefinedTemplates() string 
	return t.text.DefinedTemplates()

那么问题出在哪里呢?

随着调试过程逐渐深入,发现端倪或许在Template

进入到Template,可以看如下结构体

// Template is a specialized Template from "text/template" that produces a safe
// HTML document fragment.
type Template struct 
	// Sticky error if escaping fails, or escapeOK if succeeded.
	escapeErr error
	// We could embed the text/template field, but it's safer not to because
	// we need to keep our version of the name space and the underlying
	// template's in sync.
	text *template.Template
	// The underlying template's parse tree, updated to be HTML-safe.
	Tree       *parse.Tree
	*nameSpace // common to all associated templates

无论如何,我们的fmt.Println(t1)打印代码也是按照顺序打印Template结构体,结构体中第一个是erro,第二个是template.Template,第三个是parse.Tree,第四个是*nameSpace

这样也就能解释为什么输出结果是

&<nil> 0xc00007e0c0 0xc0001085a0 0xc00005c180

话说回来,也就是我们的这个结构体压根就没有输出text值,只有erro和内存地址值

跟text有关的我们可以看到在text/template中

text/template

源码看到这里就豁然开朗了

结构体中第一个就是name的字符串

// Template is the representation of a parsed template. The *parse.Tree
// field is exported only for use by html/template and should be treated
// as unexported by all other clients.
type Template struct 
	name string
	*parse.Tree
	*common
	leftDelim  string
	rightDelim string

所以,我们只需要修改我们的引用包位置就可以解决和例程输出不一致的问题

package main

import (
	"fmt"
	"text/template"
	// "html/template"
)

func main() 

	// ******ParseFiles()方法*****
	t1 := template.New("test")
	t1, err := t1.ParseFiles("a.cnf", "b.cnf", "c.cnf")

	// ******ParseFiles()定义*****
	// t1, err := template.ParseFiles("a.cnf", "b.cnf", "c.cnf")

	if err != nil 
		panic(err)
	
	// 先注释下面这行
	//t1.Parse("")
	fmt.Println(t1.DefinedTemplates())
	fmt.Println()
	fmt.Println(t1)
	fmt.Println(t1.Lookup("a.cnf"))
	fmt.Println(t1.Lookup("b.cnf"))
	fmt.Println(t1.Lookup("c.cnf"))


以上是关于想弄个论坛,结果发现FTP里边没有template 我该怎么办?的主要内容,如果未能解决你的问题,请参考以下文章

微信公众号下面那个空空,我想弄个接口,怎么弄

python调用百度语音(语音识别-斗地主语音记牌器)

没事自己动手弄个ftp服务器玩下

20200628-关于Android

架设服务器

Unity读取Excel文件(附源代码)