Skip to content

Commit

Permalink
✅访问标识码展示页面的入口链接
Browse files Browse the repository at this point in the history
  • Loading branch information
mewhz committed Nov 6, 2021
1 parent 533166d commit 4552ab3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/main/java/com/mewhz/paste/controller/ListController.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@
* @author mewhz
*/
@Controller
public class ListController {

public class ListController {

@ResponseBody
@RequestMapping("/list")
public String list(@RequestParam String id){
@RequestMapping(value = "/list")
public String list(@RequestParam(value = "id", required = false) String id ){

if (id == null || "".equals(id)) {
return "<h1>未输入标识码</h1>";
}

String htmlBegin = "<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" +
"<head>\n" +
Expand Down Expand Up @@ -69,4 +75,5 @@ public String list(@RequestParam String id){

return html.toString();
}

}
5 changes: 4 additions & 1 deletion src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<link rel="stylesheet" href="css/bootstrap.min.css"/>
</head>
<body class="container">
<script type="text/javascript" src="js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
Expand All @@ -23,7 +25,7 @@ <h1>
</div>
<div class="control-group">
<label>
<input class="form-control" name="identifying" type="text" placeholder="识别码(非必填)"/>
<input class="form-control" name="identifying" type="text" placeholder="识别码(非必填)" id="identifying"/>
</label>
<label>
<select class="form-control" name="type">
Expand All @@ -37,6 +39,7 @@ <h1>
<button class="btn btn-success" type="submit">提交</button>
</div>
</form>
<a id="list">根据识别码查找代码</a>
</div>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/static/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$(document).ready(()=>{
$("#list").click(()=>{
let id = $("#identifying").val();
$("#list").attr("href", "/list?id=" + id);
})
});
2 changes: 2 additions & 0 deletions src/main/resources/static/js/jquery-3.6.0.min.js

Large diffs are not rendered by default.

0 comments on commit 4552ab3

Please sign in to comment.