如何将wicket框架6.x与普通的旧jsp集成 [英] How to integrate wicket framework 6.x with plain old jsp
问题描述
我正在寻找有关如何使用jsp集成wicket 6.10的示例
我们有很多用jsp编写的代码,这是一个很好的代码,我们希望它包含在我们的wicket 1.应用程序中,以包含那些jsp文件,我们如何将其集成?
2.将jsp文件放入检票口面板中吗?
3.这些jsp文件应该在哪里?
I am looking for examples for how to ingrate wicket 6.10 with jsp
We have lots of code written in jsp , which is a good code and we want it to be in our wicket 1. application to contain those jsp files , how can we integrate it ?
2. put jsp files inside wicket panel ?
3. where should those jsp files be ?
我所做的是在Web标记内:
What I have done was inside web mark up :
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag tag) {
// Set up mock response and dispatch.
ServletContext context = WebApplication.get().getServletContext();
ServletRequest request = (HttpServletRequest) RequestCycle.get().getRequest().getContainerRequest();
MockResponse mockResponse = new MockResponse((HttpServletResponse) RequestCycle.get().getResponse().getContainerResponse());
try {
context.getRequestDispatcher("/" + pageName + ".jsp").include(request, mockResponse);
} catch (ServletException | IOException e) {
e.printStackTrace();
}
try {
replaceComponentTagBody(markupStream, tag, mockResponse.getOutput());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
class MockResponse extends HttpServletResponseWrapper {
ServletOutputStream servletStream;
ByteArrayOutputStream byteStream;
public MockResponse(HttpServletResponse response) {
super(response);
byteStream = new ByteArrayOutputStream();
servletStream = new ServletOutputStream() {
@Override
public void write(int b) {
byteStream.write(b);
}
};
}
@Override
public ServletOutputStream getOutputStream() {
return servletStream;
}
public String getOutput() throws UnsupportedEncodingException {
return byteStream.toString("UTF-8");
}
}
html的起始位置 myjsp html ... 然后是小药 我想要的是我嘲笑的所有检票口 我怎样才能做到呢?
the html is started by myjsp html ... and then thewicket psage what i want is all the wicket i have mocked to be inside my component how can i achive it ?
推荐答案
wicketstuff minis项目的新版本正在支持将jsp文件集成到wicket页面中:
the new version of the wicketstuff minis project is supporting the integration of jsp files into wicket pages:
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicketstuff-minis</artifactId>
<version>6.17.0</version><!-- or 7.0.0-M3 -->
</dependency>
仅在Wicket-WebApplication中使用以下行:
Only use the following line in your Wicket-WebApplication:
getPageSettings().addComponentResolver(new WicketServletAndJSPResolver());
然后您就可以像这样包含jsp了:
Then you are able to include jsp's like this:
<wicket:jsp file="/de/test/jspwicket/TestPage.jsp"/>
可以在相同版本的"wicketstuff-minis-example" -Projekt中找到文档.
A documentation can be found in the "wicketstuff-minis-example"-Projekt of the same version.
亲切的问候
更新后的信息(2014年10月22日):
自从Wicketstuff的新SNAPSHOT版本以来,jee集成已移至一个单独的项目:
Since the new SNAPSHOT versions of Wicketstuff the jee integration has been moved to a separate project:
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicketstuff-jee-web</artifactId>
<version>6.18.0-SNAPSHOT</version>
<!-- soon 6.18.0 --><!-- or 7.0.0-SNAPSHOT, soon 7.0.0 -->
</dependency>
班级名称已稍作更改:
getPageSettings().addComponentResolver(new JEEWebResolver());
还有很多新内容需要检查,例如带有el函数/标签的表单提交支持.
There is also a lot of new stuff to check out like form submit support with el functions / tags.
文档已移至github上的项目Wiki页面(JEE Web集成).要启用SNAPSHOT存储库,请参阅Wicketstuff的文档.
The documentation has been moved to the projects wiki page (JEE Web Integration) on github. To enable the SNAPSHOT-Repository refer to the documentation of Wicketstuff.
更新后的信息(2015年2月15日):
http://java.dzone.com/articles/integrate-jspjsf-页检票口
亲切的问候
这篇关于如何将wicket框架6.x与普通的旧jsp集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!