JSP自定义标签调用spring注入的bean
JSP自定义标签中如何才能调用spring注入的JavaBean?
按照http://topic.csdn.net/u/20080716/11/92f124e3-b51d-4610-9cfe-744317726604.html的方法做了
但是要报异常java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
求达人解惑
代码:
public class CreateTree extends org.springframework.web.servlet.tags.RequestContextAwareTag {
/**
* 树菜单数据访问对象
*/
private PopedomBiz popedomBiz;
public void setPopedomBiz(PopedomBiz popedomBiz) {
this.popedomBiz = popedomBiz;
}
/**
* 输出流
*/
private JspWriter out;
@Override
protected int doStartTagInternal() throws Exception {
popedomBiz = (PopedomBiz)this.getRequestContext().getWebApplicationContext().getBean("PopedomBiz");
out = pageContext.getOut();
pageContext.getResponse().setCharacterEncoding("utf-8");
try {
out.print(getJSFunction());//写入数据
out.print(getTreeData());//写入JS文件
out.flush();//压出数据
} catch (IOException e) {
throw new JspException(e.getMessage());
}
return SKIP_BODY;
}
}
这种方式也不行:
ApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(pageContext.getServletCon
相关问答:
//用客户的session的id建立一个临时文件:
//String tempFileName=(String)session.getId();
String tempFileName = (String)session.getId();
//out.println(& ......
问题是这样的:
我有一个文件nagiv.jsp 另一个文件failure.jsp包含他,同时nagiv文件中有一个可以跳转到yy.jsp的commandButton,但是我将failure中点击nagiv中的哪个commandButton,也面不会跳转 ......
jsp中include.inc的作用是什么?
include.inc啥意思?没听说过
Java code:
<%include file="include.inc"%>加载网站目录include.inc文件内容
包含一个静态页面吧···
& ......
<html><head><title>[@title]</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<script language='javascript'>
function diyCheck ......
新手:
tomcat+struts 2.0
jsp 页面直接关联model
现在需要根据model(admin)里面的一个item(id),判断jsp页面出现的内容.
大概流程:
...
<table>
<tr>
<td>
<s:if admin.id is null> ......