欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

list.java

struts+spring+hibernate新闻管理
JAVA
字号:
package tldbean;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import model.Roleinfo;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import service.ServiceImp;

public class list extends TagSupport{
	protected String aa;
	public int doStartTag() throws JspException {
		try {
	        WebApplicationContext wac = WebApplicationContextUtils
            .getRequiredWebApplicationContext(pageContext.getServletContext());
	        ServiceImp service = (ServiceImp) wac.getBean("ServiceImp");
			List al =  service.getUserDAO().getAll(id);
//			String x = pageContext.getRequest().getParameter("x");
//			if (x!=null) x = new String(x.getBytes(getCode(pageContext.getRequest())),"gbk");
//			System.out.println(((Student) al.get(1)).getName());
			JspWriter out = this.pageContext.getOut();
			for (int i = 0; i < al.size(); i++) {
				out.print("<OPTION value=" + ((Roleinfo) al.get(i)).getRid());
//				if (((Roleinfo) al.get(i)).getRname().equals(x)) out.print(" selected");
				out.print(">" + ((Roleinfo) al.get(i)).getRname() + "</OPTION>");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return super.doStartTag();
	}
	
	public static String getCode(ServletRequest request){
		if (request.getCharacterEncoding()==null) return "ISO_8859_1";
		return request.getCharacterEncoding();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -