Comments (2)
@KenjiOhtsuka shouldn't it be a hidden input?
val myTokenString = "..."
form(method = FormMethod.post, encType = FormEncType.applicationXWwwFormUrlEncoded, action = "/register") {
input(type = InputType.text, name = "nickname") { value = "" }
input(type = InputType.tel, name = "phone") { value = "" }
input(type = InputType.hidden, name = "token") { value = myTokenString}
}
from kotlinx.html.
I solved it.
controller
@RequestMapping("/login", method = arrayOf(RequestMethod.GET))
@ResponseBody
fun getLogin(request: HttpServletRequest): String {
return LoginView.loginForm(request)
}
template
fun loginForm(request: HttpServletRequest) = LayoutView.default("LoginForm") {
postForm(action = "/account/login") {
val csrfToken = HttpSessionCsrfTokenRepository().generateToken(request)
hiddenInput(name = csrfToken.parameterName) { value = csrfToken.token }
label {
for_ = "login_code"
+"Login Code"
}
input(type = InputType.text, name = "login_code")
label {
for_ = "password"
+"Password"
}
input(type = InputType.password, name = "password")
button { +"Login" }
}
}
when using thymeleaf, th:form automatically insert csrftoken.
when using kotlinx.html, i had to insert one by myself.
thank you.
from kotlinx.html.
Related Issues (20)
- Escaping attribute value characters break Unicode codes
- HTML5 <u> tag is missing
- Can't Download kotlinx-html-jvm from https://maven.pkg.jetbrains.space HOT 3
- Please adopt html to kotlinx.html Intellij plugin HOT 1
- Improve the documentation on custom tags
- Cannot put a div inside a th
- SAXParseException when trying to add an unclosed, raw `<link>` tag into a `head { ... }` block HOT 4
- Please make the streaming consumer easier to work with HOT 2
- htmlx
- Missing release(s), e.g. 0.11 HOT 2
- Adjust readme file to replace kotlin-js with wasm
- Add all aria attributes
- @Preview plugin for Intellij [feature]
- Rename TagConsumer.finalize()
- `attributes["hx-on::after-request"]` does not preserve double colon HOT 3
- Support path tag
- Attribute group declaration not working correctly
- Support SVG tag attributes
- TR shouldn't use TBODY as a receiver
- TBODY should be a FlowContent
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotlinx.html.