SSH 项目中,action获取jsp页面传过来的select值
项目框架S2SH,jsp页面如下,select列表设为multiple。为了能在action里取到前台界面select列表的多选值,瞎搞了两天,今天终于成功。其实后台action取前台jsp页面的值很简单,废话不多说,先贴代码:
<body>
<form action="sendMsg.action?senderId=${users.id }&username=${users.username}" method="post"
id="form" name="form" onsubmit="getIdValue()">
<input type="hidden" value="" name="" id="ids" />
<table width="500" height="220" border="1" align="center">
<tr>
<td colspan="2">
【欢迎使用】
</td>
</tr>
<tr>
<td width="88">
标题:
</td>
<td width="396">
<input type="text" name="title" id="title" />
</td>
</tr>
<tr>
<td>
内容:
</td>
<td>
<textarea name="content" id="content" cols="45" rows="5">
接收者:
${t}
action代码:
...
//定义一个与jsp页面相同的变量
private String userId; //setter getter方法略
...
public String sendMsg() throws Exception{
String username = ServletActionContext.getRequest().getParameter("username"); //获取用户名
String t[] = ServletActionContext.getRequest().getParameterValues("userId"); //这里获取时,变量名就直接写jsp页面的就行。
System.out.println(t[0]); //测试输出成功
System.out.println(t[1]);
相关文档:
1.FCKeditor 介绍
FCKeditor 这个开源的HTML 文本编辑器可以让web 程序拥有如MS Word 这样强大的编辑功能,.FCKeditor 支持当前流行的浏览器。
2.准备工作:
环境:winddows XP、tomcat6.0、JDK1.6
下载:
1):FCKeditor_2.6.4.zip
地址:http://nchc.dl.sourceforge.net/sourceforge/fckeditor/FCKeditor_2.6.4.zip ......
本例子在Windows+Tomcat6(weblogic9.2)+jdk1.6下运行。
1)安装好jdk1.6,然后安装tomcat6.
2)在tomcat目录的conf目录下,修改server.xml。
本例子是默认配置运行在虚拟目录下,,并且上传基准目录的物理路径在当前应用下。请根据第3点,在对应的host节点上加入蓝色部分代码。
1)如果应用部署在网站根目录 ......
实现JSP自定义标签的一种方法:
1.写一个类继承TagSupport或其他Tag的实现类。
public class AllTag extends TagSupport {
@Override
public int doStartTag() throws JspException {
JspWriter out = pageContext.getOut();
try {
out.append("Hello World.");
} catch (IOException e) {
e.pri ......
前言
在使用数据库的过程中,不可避免的需要使用到分页的功能,可是JDBC的规范对此却没有很好的解决。对于这个需求很多朋友都有自己的解决方案,比如使用Vector等集合类先保存取出的数据再分页。但这种方法的可用性很差,与JDBC本身的接口完全不同,对不同类型的字段的支持也不好。这里提供了一种与JDBC兼容性非常好的方案 ......
分两种:
Get方式传递数据解决办法:
<%
String username = request.getParameter("username");
byte[] bytes = username.getBytes("iso-8859-1");
String result = new String(bytes, "gb2312");
out.print(result);
%>
Post方式解决办法:request.setCharacterEncoding("gb2312");
......