jWebApp是一个基于Servlet的MVC框架,目的是为了简化小型web项目的开发复杂度。
示例:
jWebAppisliterallythissimple:
publicclassHelloWorldextendsRequestHandler{
publicStringprocessHello(ServerInterfaceserverInterface){
serverInterface.setAttribute("helloWorld","HelloWorld");
return"/WEB-INF/helloWorld.jsp";
}
publicStringprocessHelloAgain(ServerInterfaceserverInterface){
serverInterface.setAttribute("helloWorld","HelloWorldAgain");
return"/WEB-INF/helloWorld.jsp";
}
}
JustplainHTMLandyourfavoritetemplatemarkup
<divalign="center">
<h3>Hello,ThisIsASimple"HelloWorld"Example.</h3>
<h2>${helloWorld}</h2>
<p><ahref="${jwaContextPath}/helloWorld/hello">HelloWorld</a>
<p><ahref="${jwaContextPath}/helloWorld/helloAgain">HelloAgain</a>
</div>
Thefollowingservletconfigurationisallthatisneeded(outsideourcontrol,it'saservletthing).
<servlet>
<servlet-name>jwaRequestServlet</servlet-name>
<servlet-class>jwebapp.RequestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jwaRequestServlet</servlet-name>
<url-pattern>/helloWorld/hello</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jwaRequestServlet</servlet-name>
<url-pattern>/helloWorld/helloAgain</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
And,callingtheaboveissimple!
https://host/context/helloWorld/hello
https://host/context/helloWorld/helloAgain
评论