Skip to content

Commit ee25235

Browse files
committed
修正 issues 58code#1, 58code#2,
修正 ContextPath不是根目录("/")下无法正常运行的bug 提供model中默认参数 __beat,便于在view中使用 提供war:war打包plugin实例,移除web.xml的依赖
1 parent 734c50a commit ee25235

File tree

6 files changed

+31
-13
lines changed

6 files changed

+31
-13
lines changed

core/src/main/java/com/bj58/argo/Argo.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,8 @@ public File currentFolder() {
226226

227227
private File innerCurrentFolder() {
228228

229-
try {
230-
ClassLoader cl = Thread.currentThread().getContextClassLoader();
231-
URL url = cl.getResource(".");
232-
return new File(url.toURI());
233-
} catch (URISyntaxException e) {
234-
throw ArgoException.raise(e);
235-
}
229+
// System.out.println("Current Folder: " + getClass().getResource("/").getFile());
230+
return new File(getClass().getResource("/").getFile());
236231
}
237232

238233
}

core/src/main/java/com/bj58/argo/internal/DefaultArgoDispatcher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ private BeatContext bindBeatContext(HttpServletRequest request, HttpServletRespo
7878
localContext.set(context);
7979

8080
BeatContext beat = argo.injector().getInstance(defaultBeatContextKey);
81+
// 增加默认参数到model
82+
beat.getModel().add("__beat", beat);
8183
context.setBeat(beat);
8284
return beat;
8385
}

samples/company/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
<build>
2828
<plugins>
2929

30+
31+
<plugin>
32+
<groupId>org.apache.maven.plugins</groupId>
33+
<artifactId>maven-war-plugin</artifactId>
34+
<version>2.3</version>
35+
<configuration>
36+
<failOnMissingWebXml>false</failOnMissingWebXml>
37+
</configuration>
38+
</plugin>
39+
40+
41+
3042
<plugin>
3143
<groupId>org.apache.maven.plugins</groupId>
3244
<artifactId>maven-compiler-plugin</artifactId>

samples/hello-world/pom.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
<build>
2828
<plugins>
2929

30+
<plugin>
31+
<groupId>org.apache.maven.plugins</groupId>
32+
<artifactId>maven-war-plugin</artifactId>
33+
<version>2.3</version>
34+
<configuration>
35+
<failOnMissingWebXml>false</failOnMissingWebXml>
36+
</configuration>
37+
</plugin>
38+
3039
<plugin>
3140
<groupId>org.apache.maven.plugins</groupId>
3241
<artifactId>maven-compiler-plugin</artifactId>
@@ -43,7 +52,7 @@
4352
<artifactId>tomcat7-maven-plugin</artifactId>
4453
<version>2.0</version>
4554
<configuration>
46-
<path>/</path>
55+
<path>/</path> <!--/argo -->
4756
<port>80</port>
4857
</configuration>
4958
</plugin>

samples/hello-world/src/main/java/com/bj58/argo/controllers/HomeController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class HomeController extends AbstractController {
1616

1717
@Path("")
1818
public ActionResult home() {
19-
System.out.println(1);
19+
// System.out.println(1);
2020
return view("index"); // velocity模板是 /src/main/java/resources/views/index.html
2121
}
2222

samples/hello-world/src/main/resources/views/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<body>
66
<h2>Samples</h2>
77
<ul>
8-
<li><a href="/hello/world">根据url获得参数的hello wolrd</a></li>
9-
<li><a href="1.html">静态文件显示</a></li>
10-
<li><a href="form.html">区分queryString和form参数</a></li>
11-
<li><a href="upload-form.html">文件上传展示</a></li>
8+
<li><a href="$__beat.servletContext.contextPath/hello/world">根据url获得参数的hello wolrd</a></li>
9+
<li><a href="$__beat.servletContext.contextPath/1.html">静态文件显示</a></li>
10+
<li><a href="$__beat.servletContext.contextPath/form.html">区分queryString和form参数</a></li>
11+
<li><a href="$__beat.servletContext.contextPath/upload-form.html">文件上传展示</a></li>
1212
</ul>
1313
</body>
1414
</html>

0 commit comments

Comments
 (0)