beego 无法获取到页面传值

配置文件中配置了

copyrequestbody = true

请求是有localhost:8080向localhost:8088(服务端)请求的,beego中配置了跨域

页面请求:

this.$axios.post("user",{
            username:"123",
            passowrd:"321"
})

beego路由解析

    beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
      AllowOrigins:     []string{"*"},
        AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
        AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
        ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
        AllowCredentials: true,
    }))
    beego.Router("/user/?:id", &userController.UserController{})

beego中解析如下

type user struct {
    nickname string
    username string
    password string
}

func (this *UserController) Post() {
      u := user{}   //空的
      c := this.Input().Get("phone")   //空的
        if err := json.Unmarshal(this.Ctx.Input.RequestBody, &u); err == nil {
                fmt.Println(u.password)
                fmt.Println(c)
        }
}

打断点能看到this.Ctx.Input.RequestBody的len是83

页面请求Network中也能看到数据:如下图。
可就是解析不到数据

图片说明

1个回答

很简单啊,你的结构体属性应该首字母大写,
type user struct {
Nickname string
Username string
Password string
}
这样就没问题了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
如何在Go&Beego中从数据库获取数据?

<div class="post-text" itemprop="text"> <p>I try create a simple REST service on Go&amp;Beego.</p> <p>I can not understand the logic of Beego.</p> <p>All examples have information on how to retrieve just one item while I need to get all items.</p> <p>In case of API.</p> <p><strong>Controller:</strong></p> <pre><code>package controllers import ( "api/models" "github.com/astaxie/beego" ) type UserController struct { beego.Controller } func (u *UserController) GetAll() { users := models.GetAllUsers() u.Data["json"] = users u.ServeJSON() } </code></pre> <p><strong>Model:</strong></p> <pre><code>package models import ( "github.com/astaxie/beego/orm" ) var ( UserList map[int]*User ) func init() { orm.RegisterModel(new(User)) UserList = make(map[int]*User) u := User{1, "Chandler", "Bing", "chandlerbing@gmail.com"} UserList[1] = &amp;u } type User struct { Id int `form:"id"` First_name string `form:"first_name"` Last_name string `form:"last_name"` Email string `form:"email"` } func GetAllUsers() map[int]*User { return UserList } </code></pre> <p>That works! But, how can I get data from database?</p> <p>Database connections are ok (MySQL)</p> </div>

beego,找不到重新定义的页面,404页面未显示html,为什么?

<div class="post-text" itemprop="text"> <p>I redefined the <code>page_not_found</code> on router.go, </p> <pre><code>func page_not_found(rw http.ResponseWriter, r *http.Request) { t, _ := template.ParseFiles(beego.ViewsPath + "/404.html") data := make(map[string]interface{}) t.Execute(rw, data) } </code></pre> <p>and in <code>init</code> function used </p> <p><code>beego.Errorhandler("404", page_not_found)</code></p> <p>when i called 404 by used <code>this.Abort("404")</code> in controller, the 404 page was not show html, it showed the page html text, liked this</p> <p><img src="https://i.stack.imgur.com/KIkWc.png" alt="html text/plain"></p> </div>

如何从beego AppConfig获取值并将其呈现在HTML模板中?

<div class="post-text" itemprop="text"> <p>I want to get value of a key defined in beego's <strong>app.conf</strong> and render in html pages. As per documentation on <a href="http://beego.me/docs/mvc/view/template.md" rel="nofollow">http://beego.me/docs/mvc/view/template.md</a> I can get value of AppConfig by using config function in templates. However there is no example in documentation.</p> <blockquote> <p>Get the value of AppConfig. {{config configType configKey defaultValue}}. configType must be String, Bool, Int, Int64, Float, or DIY</p> </blockquote> <p>After trying many ways I came to this:</p> <pre><code>&lt;div&gt;{{config config.String config.appname "TestDefaultValue"}}&lt;/div&gt; </code></pre> <p>But I am always getting error:</p> <pre><code>&lt;config&gt;: wrong number of args for config: want 3 got 0 </code></pre> <p>What is the correct way to use config template function?</p> </div>

Beego:如何在会话超时时重定向到其他页面

<div class="post-text" itemprop="text"> <p>i am handling session variable by setting time out using </p> <pre><code>globalSessions, _ = session.NewManager("memory", `{"cookieName":"gosessionid", "enableSetCookie,omitempty": true, "gclifetime":5, "maxLifetime": 5, "secure": false, "sessionIDHashFunc": "sha1", "sessionIDHashKey": "", "cookieLifeTime": 3600, "providerConfig": ""}`) go globalSessions.GC() sess, _ := globalSessions.SessionStart(c.Ctx.ResponseWriter, c.Ctx.Request) defer sess.SessionRelease(c.Ctx.ResponseWriter) errU := sess.Set("user1", c.Input().Get("userName")) if errU != nil { fmt.Println("error in settng value") } </code></pre> <p>now how to redirect back to specific page on time out of the current page. I have this application in beego</p> </div>

Beego:如何解析对象url参数?

<div class="post-text" itemprop="text"> <p>The URL I am receiving looks like this:</p> <pre><code>/controller/action?columns[0][data]=foo&amp;columns[1][data]=bar&amp;columns[2][data]=bar&amp;columns[3][data]=bar&amp;columns[4][data]=bar </code></pre> <p>So I have an array of objects. How can I parse this into a slice of structs?</p> <p>What I have in my controller action is this:</p> <pre><code>func (this *MyController) Foo() { type column struct{ Data string } columns := []column{} if err := this.Ctx.Input.Bind(&amp;columns, "columns"); err != nil { log.Fatal(err) } else { log.Println("OK, got:", columns) } } </code></pre> <p>And the output of this is:</p> <pre><code>OK, got: [{} {} {} {} {} {}] </code></pre> <p>Bind successfully detects there are five columns but fails to map the <code>data</code> field. I experimented with this and believe there are two problems:</p> <p>The bind seems to only support the exact syntax shown in the <a href="http://beego.me/docs/mvc/controller/params.md#data-bind" rel="nofollow">documentation</a>:</p> <pre><code>?id=123&amp;isok=true&amp;ft=1.2&amp;ol[0]=1&amp;ol[1]=2&amp;ul[]=str&amp;ul[]=array&amp;user.Name=astaxie </code></pre> <p><code>user.Name=astaxie</code> works while <code>user[Name]=astaxie</code> does not.</p> <p>The 2nd problem is, the lower case of <code>data</code>. My experiments have shown <code>user.Name</code> works while <code>user.name</code> does not.</p> <p>So the data bind method expects me to get the parameters in the form <code>columns[0].Data=foo</code> while I have <code>columns[0][data]=foo</code></p> <p>The first one indeed works. But I have no control over the URL, I have to accept it as it is, with lower case <code>data</code> in square brackets. The request is generated by <a href="https://datatables.net/manual/server-side#Sent-parameters" rel="nofollow">DataTables</a>.</p> </div>

与beego中的列表相关

<div class="post-text" itemprop="text"> <p>I am wondering how the correct approach is to load related fields in beego. The <a href="https://beego.me/docs/mvc/model/query.md" rel="nofollow noreferrer">doc</a> explains it like this:</p> <pre><code>type User struct { Id int Name string Posts []*Post `orm:"reverse(many)"` } user := User{Id: 1} err := dORM.Read(&amp;user) num, err := dORM.LoadRelated(&amp;user, "Posts") </code></pre> <p>This makes sense as long as I only query one record. What is the correct way to fetch related fields when I query all users?</p> <p>A possible solution would be like this:</p> <pre><code>var users []*User o.QueryTable(new(User)).All(&amp;users) for _, user := range users { o.LoadRelated(controlCategory, "Posts") } </code></pre> <p>However, this means I have to loop everytime over the complete list and make for every record a DB query to load all records. </p> <p>Any suggestions? Thanks!</p> </div>

如何在Golang Beego中解析表单数组

<div class="post-text" itemprop="text"> <p>How to parse html form array with Beego.</p> <p> <code>&lt;input name="names[]" type="text" /&gt; &lt;input name="names[]" type="text" /&gt; &lt;input name="names[]" type="text" /&gt;</code></p> <p>Go Beego</p> <pre class="lang-html prettyprint-override"><code>type Rsvp struct { Id int `form:"-"` Names []string `form:"names[]"` } rsvp := Rsvp{} if err := this.ParseForm(&amp;rsvp); err != nil { //handle error } input := this.Input() fmt.Printf("%+v ", input) // map[names[]:[name1 name2 name3]] fmt.Printf("%+v ", rsvp) // {Names:[]} </code></pre> <p>Why Beego ParseForm method return an empty names?</p> <p>How to get values into rsvp.Names?</p> </div>

如何将变量传递给模板并在beego中接收变量

<div class="post-text" itemprop="text"> <p>My template file:</p> <pre><code>{{range $index, $option := .alternatives}} &lt;div id="splashAlternative{{$index}}" class="col-sm-2"&gt; &lt;select id="flashSrc_{{$index}}"&gt; {{template "alternative_src.html" $option}} &lt;/select&gt; &lt;/div&gt; {{end}} </code></pre> <p>I want pass <code>$option</code> to template, and <code>alternative_src.html</code> code :</p> <pre><code>{{if compare .option ""}} &lt;option value="" selected="selected"&gt; &lt;/option&gt; {{else}} &lt;option value=""&gt;&lt;/option&gt; {{end}} {{if compare .option "xxx"}} &lt;option value="xxx" selected="selected"&gt;xxx&lt;/option&gt; {{else}} &lt;option value="xxx"&gt;xxx&lt;/option&gt; {{end}} </code></pre> <p>but I get problem below:</p> <pre><code>executing "alternative_src.html" at &lt;.option&gt;: can't evaluate field option in type string </code></pre> </div>

Beego会话不会自动将数据传递到模板

<div class="post-text" itemprop="text"> <p>Upon getting session information of type <code>map[string]interface{}</code> with <code>this.GetSession("session_key")</code>, I did have to explicitly set the context and type assert the session like this in order to explicitly pass the data to the template.</p> <pre><code>// Get the session profile := this.GetSession("profile") // Have to add data to the template's context this.Data["nickname"] = profile.(map[string]interface{})["nickname"].(string) this.Data["picture"] = profile.(map[string]interface{})["picture"].(string) // Render template this.TplNames = "user.html" </code></pre> <p>The session data (type <code>map[string]interface{}</code>) looks like this:</p> <pre><code>{"nickname": "joe", "picture": "urltotheimg"} </code></pre> <p>However, according to the Beego's session <a href="http://beego.me/docs/mvc/controller/session.md" rel="nofollow">doc</a>, it looks like the session is passed implicitly without any need of type assertions or context passing (the template has immediate access to session values i.e. <code>{{.nickname}}</code> and <code>{{.picture}}</code>)</p> <p>This is the controller setting the session before redirecting to <code>/user</code></p> <pre><code>// Inherit beego's base controller type MyController struct { beego.Controller } func (this *MyController) Get() { // code for getting token here // Getting the User information client := conf.Client(oauth2.NoContext, token) resp, err := client.Get("https://" + domain + "/userinfo") if err != nil { this.Redirect("/error", 500) return } // Reading the body for user's information raw, err := ioutil.ReadAll(resp.Body) defer resp.Body.Close() if err != nil { this.Redirect("/error", 500) return } // Unmarshalling the JSON of the Profile var profile map[string]interface{} if err := json.Unmarshal(raw, &amp;profile); err != nil { this.Redirect("/error", 500) return } // Saving the information to the session. this.SetSession("profile", profile) // redirect to /user this.Redirect("/user", 301) } </code></pre> <p>This is the controller of "/user"</p> <pre><code>type UserController struct { beego.Controller } func (this *UserController) Get() { // get the saved session profile := this.GetSession("profile") // without setting the template data here, the session data won't be // available in user.html this.Data["nickname"] = profile.(map[string]interface{})["nickname"].(string) this.Data["picture"] = profile.(map[string]interface{})["picture"].(string) this.TplNames = "user.html" } </code></pre> <p>Only this then I can map the template to the data like this:</p> <pre><code>&lt;img src="{{ .picture }}"&gt; &lt;p&gt;Hello, {{ .nickname }}&lt;/p&gt; </code></pre> <p>I'm quite sure it's necessary to set the template data. I'm just not sure why the above doc didn't do that. </p> <p>Any help would be appreciated.</p> </div>

Beego:显示登录用户名,该用户名取自表单的输入字段

<div class="post-text" itemprop="text"> <p>I am using Beego framework for my purpose and i have two html view files one is login and other is landing login.html </p> <p></p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="/commonDashboard" name="loginForm" method="post" autocomplete="off" id="loginForm" &gt; &lt;input type="text" placeholder="Enter your user name" id="userName" name="userName" taborder="1"&gt; &lt;input type="password" class="qwerty" placeholder="Enter your password" id="userPassword" name="userPassword" taborder="2"&gt; &lt;input type="button" value="Login" onclick="validatelogin();" taborder="3"&gt; &lt;input type="button" value="Clear" onclick="resetForm();" taborder="3"&gt; &lt;span class="forgot"&gt;&lt;a href="#"&gt;forgot password ?&lt;/a&gt;&lt;/span&gt; &lt;!-- Virtual Keyboard --&gt; &lt;span class="virtual"&gt;&lt;a href="#" id="passwd" class="tooltip-tipsy" title="Click to open the virtual keyboard"&gt;Virtual Keyboard &lt;/span&gt; &lt;/form&gt; </code></pre> </div> </div> <p>and landing page is</p> <p></p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;header class="top"&gt; &lt;div class="container-fluid"&gt; &lt;aside class="logo"&gt;&lt;img src="img.jpg" class="img-responsive"&gt;&lt;/aside&gt; &lt;aside class="top-right"&gt; &lt;div class="profile"&gt; &lt;ul&gt; &lt;li class="name"&gt;&lt;img src="../static/img/profile-img.jpg" alt="Shri Ram"&gt; Hi &lt;a href="#"&gt;Shri&lt;/a&gt;&lt;/li&gt; &lt;li class="logout"&gt;&lt;a href="/login"&gt;Logout&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Contacts&lt;/a&gt;&lt;/li&gt; &lt;li class="last"&gt;&lt;a href="#"&gt;Help&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="login-time"&gt; &lt;ul&gt; &lt;li&gt;&lt;span&gt;Current Login:&lt;/span&gt; Mon 22 Sep 2014 03:28 PM&lt;/li&gt; &lt;li class="last"&gt;&lt;span&gt;Last Login:&lt;/span&gt; Sun 21 Sep 2014 02:28 PM&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/aside&gt; &lt;/div&gt; &lt;/header&gt;</code></pre> </div> </div> <p>and controller is as follows</p> <p></p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>package controllers import ( "fmt" "github.com/astaxie/beego" ) type MainController struct { beego.Controller } func (c *MainController) Get() { c.TplNames = "login.html" fmt.Println("login Get Method") } type LoginController struct { beego.Controller } func (c *LoginController) Post() { c.TplNames = "commonDashboard.html" fmt.Println("this is dashboard") password := c.Input().Get("userPassword") username := c.GetSession("userName").(string) c.SetSession("userName", username) c.Data["user"] = username fmt.Println("password:" + " " + password) } type HeaderController struct { beego.Controller } func (c *HeaderController) Get() { fmt.Println("this is Header") username := c.Input().Get("userName") fmt.Println(username) c.TplNames = "commonHeader.html" } type FooterController struct { beego.Controller } func (c *FooterController) Get() { fmt.Println("this is footer") c.TplNames = "commonFooter.html" } type MenuController struct { beego.Controller } func (c *MenuController) Get() { fmt.Println("this is menu") c.TplNames = "commonMenu.html" }</code></pre> </div> </div> <p>i want to display the currently logged in username in header of html file </p> </div>

在Angular js中从Go模板获取数据

<div class="post-text" itemprop="text"> <p>I am new in Angular Js. I managed to receive the data from golang in angular js. But it's giving an output <strong>[object Object]</strong> when used in an alert box. I tried changing the delimiters of golang from <strong>{{ }}</strong> to <strong>&lt;&lt;&lt; &gt;&gt;&gt;</strong>, but the problem was not solved.</p> <p>Go code: (I am using beego)</p> <pre><code>func (receiver *AdsController) LoadNewCampaignPage() { view := viewmodels.NewCampaignPageViewModel{} view.Title = "New Campaign" receiver.Data["vm"] = view receiver.Layout = "layouts/ads_header.html" receiver.TplName = "templates/ads_add_campaign.html" } </code></pre> <p>Struct <strong>viewmodels.NewCampaignPageViewModel{}</strong></p> <pre><code>type NewCampaignPageViewModel struct { Title string ProfileName string ProfilePicture string UnUsedBoxes []models.Box ErrorMessage string } </code></pre> <p>Html</p> <pre><code>&lt;div ng-controller="AddBoxForAdsCtrl"&gt; &lt;button class="_button _button-3" ng-click="showHiddenForm()"&gt;Add Box&lt;/button&gt; &lt;/div&gt; </code></pre> <p>JS</p> <pre><code>var addBoxForAds = angular.module('addBoxForAds', []); addBoxForAds.controller('AddBoxForAdsCtrl', function ($scope, $http){ var title = $http.get('&lt;&lt;&lt;.vm.Title&gt;&gt;&gt;'); //Data from GO; delimiters are changed. alert(title); }); </code></pre> <p>What are the mistakes I made here? How can I get the data from golang in angularjs? How to use use the struct element <strong>UnUsedBoxes</strong>(which is an array of struct)?</p> </div>

使用Beego将服务器API转发到另一个端口

<div class="post-text" itemprop="text"> <p>I have two web apps running in the same virtual machine. One is Beego listening to port 443, and another is Centrifugo messaging server at port 8000. </p> <p>If a user is not allowed to connect port 8000 due to his ISP, is it possible that I forward <a href="https://my.domain/chat_api" rel="nofollow noreferrer">https://my.domain/chat_api</a> (intercepted by Beego at port 443) to <a href="https://my.domain:8000/chat_api" rel="nofollow noreferrer">https://my.domain:8000/chat_api</a> (served by Centrifugo at port 8000), so that my chat client connects port 443 just like connecting port 8000? If yes, how do I implement under Beego's structure?</p> </div>

Beego处理后在中间件中获得响应主体

<div class="post-text" itemprop="text"> <p>I have to append parameter in JSON response after request processing is completed and before sending. I can do in <code>after exec</code> filter. Here I defined filter like this,</p> <pre><code>beego.InsertFilter("*", beego.AfterExec, AddRequestAfterExec, false) </code></pre> <p>Now in this <code>AddRequestAfterExec</code> method, I am unable to read JSON response. I need to read JSON response and add parameter to it. I searched many things, but did not find any thing useful. So far I have left it empty. </p> <pre><code>func AddRequestAfterExec(c *context.Context) {} </code></pre> <p>Can anybody help, how to read Response in this function and modify it?</p> <p>Also I am sending response from API controller like this </p> <pre><code>authController.ServeJSON() </code></pre> </div>

如何在beg orm中获取最终的sql字符串

<div class="post-text" itemprop="text"> <p>I want to get the finally sql string in the beego's orm.</p> <p>but I can not find the interface that can get sql string.</p> <p>I want to make a Logging for database Operating.</p> <p>I want to find other ways that do not need to turn on the orm.Debug. </p> <pre><code>orm.Debug = false </code></pre> </div>

如何修改beego项目的目录结构?

<div class="post-text" itemprop="text"> <pre><code>bee :1.4.1 beego :1.6.1 Go :go version go1.6.3 windows/amd64 set GOARCH=amd64 set GOBIN= set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\GoSites set GORACE= set GOROOT=C:\Go set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GO15VENDOREXPERIMENT=1 set CC=gcc set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 set CXX=g++ set CGO_ENABLED=1 </code></pre> <p>I am busy using the Beego framework for golang, and I am trying to modify the directory structure. </p> <p>I moved the controllers, models, static, and views directories into a new directory 'app' in order to clean up the directory structure, this caused a number of routing and file path errors eg:</p> <blockquote> <p>can't find templatefile in the path:index.tpl</p> </blockquote> <p>How do I modify the project to account for the changing of the directory structure without causing errors?</p> <p>Thanks</p> </div>

beego api发布插入数据

<div class="post-text" itemprop="text"> <p>First of all. I use postman to POST data. How to take data from the postman key. It works by using this way (in my code I set it by myself).</p> <p>I want to get firstname, lastname, email in form-data. I want to use as below.</p> <pre><code>func InsertOneUser(user User) *User { o := orm.NewOrm() qs := o.QueryTable(new(User)) i, _ := qs.PrepareInsert() var u User user.FirstName = "firstname" &lt;----- this user.LastName = "lastname" &lt;----- this user.Email = "something@yahoo.com" &lt;----- this user.Password, _ = hashPassword(user.Password) user.RegDate = time.Now() id, err := i.Insert(&amp;user) return &amp;u } </code></pre> <p><a href="https://i.stack.imgur.com/MDb7G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MDb7G.png" alt="enter image description here"></a></p> </div>

Beego Controller中的JSON响应

<div class="post-text" itemprop="text"> <p>I'm a newbie to beego trying to get a JSON response on a route.</p> <p>I have a controller defined as such.</p> <pre><code>package controllers import ( "github.com/astaxie/beego" ) type ErrorController struct { beego.Controller } type ErrorJson struct { s string d string } func (this *ErrorController) Get() { var responseJson ErrorJson responseJson = ErrorJson{ s: "asdf", d: "qwer", } this.Data["json"] = responseJson this.ServeJson() } </code></pre> <p>My router is defined as </p> <pre><code>beego.Router("/api", &amp;controllers.ErrorController{}) </code></pre> <p>When I visit the route, I get an Empty JSON object without any properties.</p> <pre><code>{} </code></pre> <p>If I replace the json struct with a string, I get a response. So beego is aware of the controller and the method. </p> <pre><code>this.Data["json"] = "Hello World" </code></pre> <p>What am I doing wrong?</p> </div>

Beego不接受Ajax参数

<div class="post-text" itemprop="text"> <p>I'm trying to make simple POST request using VueJS to an application which is written in Beego framework (GoLang) but the application doesn't see any input request. Everything is ok when I use standard form request (no ajax). This is my VueJS code:</p> <pre><code>storePost: function(event) { axios.post("/api/posts/store", {body: "test"}).then(function(response) { if (response.data.status == 200) { this.posts.push(response.data.data); }else { console.log("error"); } }, function(response){ console.log("error"); }); } </code></pre> <p>and this is my Beego code:</p> <pre><code>// router.go beego.Router("/api/posts/store", &amp;controllers_API.PostsController{}, "post:Store") // PostsController.go func (this *PostsController) Store() { fmt.Println(this.GetString("body")) // some irrelevant code which handles the response... } </code></pre> <p><code>fmt.Println</code> always prints nothing. When I use standard forms <code>fmt.Println</code> prints the value of the <code>body</code> with no problems.</p> </div>

如何在Beego的模板文件中获取范围索引

<div class="post-text" itemprop="text"> <p>For example</p> <pre><code>{{ range .cars }} {{.color}} , ${{.price}} {{ end }} </code></pre> <p>The array size of 'cars' is 10. How do I get the index value?</p> <p>When the index is 5, I want do some process.</p> <p>I am using Beego web framework.</p> </div>

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

一文带你入门Java Stream流,太强了

两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:“就想看你写的啊!”你看你看,多么苍白的喜欢啊。那就“勉为其难”写一篇吧,嘻嘻。 单从“Stream”这个单词上来看,它似乎和 java.io 包下的 InputStream 和 OutputStream 有些关系。实际上呢,没毛关系。Java 8 新增的 Stream 是为...

立即提问
相关内容推荐