From 53e6854e143b5f17d4bad50d95643c3e40a857ae Mon Sep 17 00:00:00 2001 From: "guowen.qi" Date: Sun, 7 Dec 2025 10:50:54 +0800 Subject: [PATCH] init commit 12.07 --- HELP.md | 21 ++++ pom.xml | 91 ++++++++++++++++++ .../java/com/sky/web/SkyWebApplication.java | 13 +++ .../sky/web/demos/web/BasicController.java | 67 +++++++++++++ .../web/demos/web/PathVariableController.java | 44 +++++++++ src/main/java/com/sky/web/demos/web/User.java | 43 +++++++++ src/main/resources/application.properties | 3 + src/main/resources/static/index.html | 6 ++ .../com/sky/web/SkyWebApplicationTests.java | 13 +++ target/classes/application.properties | 3 + .../com/sky/web/SkyWebApplication.class | Bin 0 -> 699 bytes .../sky/web/demos/web/BasicController.class | Bin 0 -> 2264 bytes .../demos/web/PathVariableController.class | Bin 0 -> 1447 bytes .../classes/com/sky/web/demos/web/User.class | Bin 0 -> 781 bytes target/classes/static/index.html | 6 ++ 15 files changed, 310 insertions(+) create mode 100644 HELP.md create mode 100644 pom.xml create mode 100644 src/main/java/com/sky/web/SkyWebApplication.java create mode 100644 src/main/java/com/sky/web/demos/web/BasicController.java create mode 100644 src/main/java/com/sky/web/demos/web/PathVariableController.java create mode 100644 src/main/java/com/sky/web/demos/web/User.java create mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/static/index.html create mode 100644 src/test/java/com/sky/web/SkyWebApplicationTests.java create mode 100644 target/classes/application.properties create mode 100644 target/classes/com/sky/web/SkyWebApplication.class create mode 100644 target/classes/com/sky/web/demos/web/BasicController.class create mode 100644 target/classes/com/sky/web/demos/web/PathVariableController.class create mode 100644 target/classes/com/sky/web/demos/web/User.class create mode 100644 target/classes/static/index.html diff --git a/HELP.md b/HELP.md new file mode 100644 index 0000000..a1eaeef --- /dev/null +++ b/HELP.md @@ -0,0 +1,21 @@ +# Getting Started + +### Reference Documentation + +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.4.2/maven-plugin/reference/html/) +* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.4.2/maven-plugin/reference/html/#build-image) +* [Arthas](https://arthas.gitee.io/index.html) +* [Spring Web](https://docs.spring.io/spring-boot/docs/2.4.2/reference/htmlsingle/#web) +* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/2.4.2/reference/htmlsingle/#using.devtools) + +### Guides + +The following guides illustrate how to use some features concretely: + +* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) +* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) +* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/) + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..4b68d47 --- /dev/null +++ b/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + com.sky.web + skyweb + 0.0.1-SNAPSHOT + skyweb + skyweb + + 1.8 + UTF-8 + UTF-8 + 2.4.2 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + UTF-8 + + + + org.apache.maven.plugins + maven-resources-plugin + 3.2.0 + + UTF-8 + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + com.sky.web.SkyWebApplication + true + + + + repackage + + repackage + + + + + + + + diff --git a/src/main/java/com/sky/web/SkyWebApplication.java b/src/main/java/com/sky/web/SkyWebApplication.java new file mode 100644 index 0000000..88af6b2 --- /dev/null +++ b/src/main/java/com/sky/web/SkyWebApplication.java @@ -0,0 +1,13 @@ +package com.sky.web; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SkyWebApplication { + + public static void main(String[] args) { + SpringApplication.run(SkyWebApplication.class, args); + } + +} diff --git a/src/main/java/com/sky/web/demos/web/BasicController.java b/src/main/java/com/sky/web/demos/web/BasicController.java new file mode 100644 index 0000000..d4a27e3 --- /dev/null +++ b/src/main/java/com/sky/web/demos/web/BasicController.java @@ -0,0 +1,67 @@ +/* + * Copyright 2013-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sky.web.demos.web; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * @author theonefx + */ +@Controller +public class BasicController { + + // http://127.0.0.1:8080/hello?name=lisi + @RequestMapping("/hello") + @ResponseBody + public String hello(@RequestParam(name = "name", defaultValue = "unknown user") String name) { + return "Hello " + name; + } + + // http://127.0.0.1:8080/user + @RequestMapping("/user") + @ResponseBody + public User user() { + User user = new User(); + user.setName("theonefx"); + user.setAge(666); + return user; + } + + // http://127.0.0.1:8080/save_user?name=newName&age=11 + @RequestMapping("/save_user") + @ResponseBody + public String saveUser(User u) { + return "user will save: name=" + u.getName() + ", age=" + u.getAge(); + } + + // http://127.0.0.1:8080/html + @RequestMapping("/html") + public String html() { + return "index.html"; + } + + @ModelAttribute + public void parseUser(@RequestParam(name = "name", defaultValue = "unknown user") String name + , @RequestParam(name = "age", defaultValue = "12") Integer age, User user) { + user.setName("zhangsan"); + user.setAge(18); + } +} diff --git a/src/main/java/com/sky/web/demos/web/PathVariableController.java b/src/main/java/com/sky/web/demos/web/PathVariableController.java new file mode 100644 index 0000000..557de83 --- /dev/null +++ b/src/main/java/com/sky/web/demos/web/PathVariableController.java @@ -0,0 +1,44 @@ +/* + * Copyright 2013-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sky.web.demos.web; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * @author theonefx + */ +@Controller +public class PathVariableController { + + // http://127.0.0.1:8080/user/123/roles/222 + @RequestMapping(value = "/user/{userId}/roles/{roleId}", method = RequestMethod.GET) + @ResponseBody + public String getLogin(@PathVariable("userId") String userId, @PathVariable("roleId") String roleId) { + return "User Id : " + userId + " Role Id : " + roleId; + } + + // http://127.0.0.1:8080/javabeat/somewords + @RequestMapping(value = "/javabeat/{regexp1:[a-z-]+}", method = RequestMethod.GET) + @ResponseBody + public String getRegExp(@PathVariable("regexp1") String regexp1) { + return "URI Part : " + regexp1; + } +} diff --git a/src/main/java/com/sky/web/demos/web/User.java b/src/main/java/com/sky/web/demos/web/User.java new file mode 100644 index 0000000..32943dd --- /dev/null +++ b/src/main/java/com/sky/web/demos/web/User.java @@ -0,0 +1,43 @@ +/* + * Copyright 2013-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sky.web.demos.web; + +/** + * @author theonefx + */ +public class User { + + private String name; + + private Integer age; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..e52b498 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,3 @@ +# 应用服务 WEB 访问端口 +server.port=8080 + diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html new file mode 100644 index 0000000..89bb8ba --- /dev/null +++ b/src/main/resources/static/index.html @@ -0,0 +1,6 @@ + + +

hello word!!!

+

this is a html page

+ + \ No newline at end of file diff --git a/src/test/java/com/sky/web/SkyWebApplicationTests.java b/src/test/java/com/sky/web/SkyWebApplicationTests.java new file mode 100644 index 0000000..82063da --- /dev/null +++ b/src/test/java/com/sky/web/SkyWebApplicationTests.java @@ -0,0 +1,13 @@ +package com.sky.web; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SkyWebApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/target/classes/application.properties b/target/classes/application.properties new file mode 100644 index 0000000..e52b498 --- /dev/null +++ b/target/classes/application.properties @@ -0,0 +1,3 @@ +# 应用服务 WEB 访问端口 +server.port=8080 + diff --git a/target/classes/com/sky/web/SkyWebApplication.class b/target/classes/com/sky/web/SkyWebApplication.class new file mode 100644 index 0000000000000000000000000000000000000000..f776193fcaadedae40e64aebaa48a932d4e44ef8 GIT binary patch literal 699 zcmaJ<%TC)s6g?9H4kj%SAe25-u?tx+8^k6E2_mtwKx$A}bTxJdcZfX`jmJDbi&ZNY zd;lMXxMPqKiL_qatNS|Vo;!Yees~11hp!>(SP!rfqK(Y}pBNSnlveJLVXm_?WT^Me zFUhbRDJ@USJeKxc#2IB;kx4{06ju58Em?QJRl)E*N=(j+(H*~$F&~WXE@XT(9%m{M zP8r=J*jy;h(C++d zJC)0!Dim#aq_uGsJ>eck#-_X&d%jC6a(QFyh{wh_E=p$-qc2rjTFD1h%P|$E_ithz z3k=`>t1`e=6QA*gVPzumEWVP7W9a^q|CMoyjb6f*bgQ^Cb*g?QilR5;Iy*C!ksv2; z9q+#h^G`NKL1|y^VH-92A^cYZ^CHOx6mjy5{CxKh*nL%Qko9Fy!y?({YXd?oQM5?$ s2g>;2{R#|dv})bIn7f$Fhg1Pg1T-_jXy7B3DPO}%WmnN6@44217eR8gSO5S3 literal 0 HcmV?d00001 diff --git a/target/classes/com/sky/web/demos/web/BasicController.class b/target/classes/com/sky/web/demos/web/BasicController.class new file mode 100644 index 0000000000000000000000000000000000000000..db630a11a864b15b71f4e55d57d32c65842919f8 GIT binary patch literal 2264 zcmb7E>vGdZ6#mv%;i`#aaw#bVgSj|1j<}>i6G*W`X+oWZCSVG*1v%c>BC_P_l8`=1 zpQ8O^m@?A`=tFgSR+3}K5t)f+tld3(&Ue0Z+kgN2`yT*vc$2~e7L)ikg$NcUJP>PH zd@4ySrH~ZDhhqIMg-7^a?3N|0i1o3AAH-S}>Z=mgB&;X#B#9px68AJia~2t*`I#C+ zY{_hJhS92K@HMwx=hjoTu9GBFHMdl~rdpaf2f~=s(rkvS)h)BF*gN~m93UWa zYCbC_@4k$m1#IG4mJ&y&U+}AN_nM-mIpXhT{Ypu{w`h`W)nK?B&R{4V4C#JY>-D#M z%ONi`gWPB^ltPMqv{QmSQ2Hgu^dAw1q|Kc*@6DJ91ECfe>pKp*hOE4qU*Be!%&!c3 z>h%?oBjB=Vp2jj7l7^l}?{1PAnn4<3& zbW&(#w8jhX!TzF61ZM&z;44hiUiKC6CC<``k@Os*p7AniM@TmQ5s??~5zWN9h!^SK zMdDAA4`Ss!tVv%#z#>bWN0u-zkamXdF48{t3e3hOTqfBS`i}{QSLyP+P1<=IGjuMX zND>jjOIihq>5oVf38`Aloa!P~9E<$%0iSgt7yDE)h>>Oi5?PPn8rhcyXiW#SB%)HF z+b~)sj~2r$WzP5iJn*0ECE;^F2_v**M*V%di?NWL%ndlt9pog3>z{CbBXE8bw*u!S zA}Puj&1CvfiV6es1I3F5;3CZ3Ovu%0Vet;&sGk138%-NaQ{`vd!H-Kq8iy(qz2xAchkPKto$W#~;MyA7< z3_*tQSfJyj?b!O2KrlJBF3`5%7L-7D#&*<)YB{I8RV!Dbr8nc|tz zFEE+OyJhKb@5^14lLb|F{hGFH>CKaf1=rD@TPi7UP9R)VI^z~?M_?wI*|K&lS+bm> zT+yEG6z7^PW6dT~ulmYcDj04}5IkizWljgORY%)pwQl=1slRp{S6kY49WtNExL#5E z6_fUhXO-2i>uuM#=WM4Sty5o_RbQ*h*YB-L#ZVMz-?2(n7A7tY4S7%}b0|$(Umn!6 zACgB|=}nhBUR*g>Es&{#Zx>euo?ju}ukdCY(^FS6oRy}Wv3n-Ls5 zpZRQ_CJlf#9S0zhzj)oKQ{AKyHrpf^RBU{iKRkfHW9@Xo(Oa$ zvTW>$=_#gZTFWjaSWQhYfr+cU0fC;g+#hpWDz7;yoGs;WQqq?yV}mSP5Y}$}J~Kd1z7oqI>k7)LjC<4Ong;07h%8g3HA1aHtg zNE!cyz^7vbd)toCp5p55;5NZ^gwS_7oCh7LfhOvK4NyWLhFguKebfTzXWU)N+gt-1 z5I*i;kW$ea$333j=jsnID8V)06X8_tqdJ7)2G4hd2+%op!ZY09*@E79jb2~f|CC+~ eBQ<)>q#m>&#lbpdGD4(>%pJgJ?MkMykAQy+(QPFF literal 0 HcmV?d00001 diff --git a/target/classes/com/sky/web/demos/web/User.class b/target/classes/com/sky/web/demos/web/User.class new file mode 100644 index 0000000000000000000000000000000000000000..fa64a4356fa8176584e1d9300bf4922e41ddc66f GIT binary patch literal 781 zcmZ{hTT22#6vzMLWjA$8^Rks`Hwe_Aed(9QJ7H(tw9p9Ko2WS@X^aeA2ueIz1Jq(lEWXed%-HS!GlGZC%5gT2VIRkDf<>R6+*_FI57GUPF= zBTII+`4y4px#sf1<{a|l=DK8~QMIEtM5d#Y6bJFgaUd0R=_}*$0!{2As0+{+fJEm( c4i|!KU~>^jbRMKiAhjhR;z9+;mR!B~17yK}p#T5? literal 0 HcmV?d00001 diff --git a/target/classes/static/index.html b/target/classes/static/index.html new file mode 100644 index 0000000..89bb8ba --- /dev/null +++ b/target/classes/static/index.html @@ -0,0 +1,6 @@ + + +

hello word!!!

+

this is a html page

+ + \ No newline at end of file