你发贴也发错了 不过我是从java版过来的 多给点分是才硬道理!!
解决方案 »
- 帮忙哇!SpringMVC 怎么才可以跟struts是的 把页面参数包装成实体类
- 异常
- JMS Activemq配置问题。
- hibernate - ExceptionInInitializerError
- 单个程序编译都通过,运行是却出错
- 学web services很迷茫,不知道将来能怎么运用啊!!!
- 北京的JAVA程序员请进!单独找人付费培训
- Struts的问题(两个List)急,急,急!!!!!!!!
- 问一下会话BEAN实现类中的setSessionContext方法的作用,希望大家进来看一下,谢谢
- ~~~再也不能这样活~~~
- 我在sun网站下载的j2se1.5,一共43.9M,安装时复制到最后报错:1335,DATA1.cab不能用.是我下的文件有问题吗?
- 配置tomcat的时候总是出现问题。
<html:form action=<%out.print(saction);%>>
或者
<html:form action=<%out.print("\""+saction+"\"");%>>
这样应该可以
我的是这样的
<%
String a = "/net/createBill";
%>
<html:form action="<%=a%>" styleId="createIncomeBill" method="post" >不知道你的是怎么样的
这种写法不是有违标签的初衷吗?另外如何解析的问题,完全是写这个标签的人和jsp规范决定的。以我来说,我建议你不要这么用。
<name>form</name>
<tagclass>org.apache.struts.taglib.html.FormTag</tagclass>
<bodycontent>JSP</bodycontent>
<attribute>
<name>action</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
上面<required>true</required>说明该<html:form/>标签该属性是必须的,<rtexprvalue>true</rtexprvalue>说明该属性可以运行时动态求值,可以<%=...%>
hellundertaker(向南奔跑的风) (
用双引号括住当然是这样啦
<html:form action=<%out.print(saction);%>>
或者
<html:form action=<%out.print("\""+saction+"\"");%>>
这样应该可以
hellundertaker(向南奔跑的风) (
用双引号括住当然是这样啦
<html:form action=<%out.print(saction);%>>
或者
<html:form action=<%out.print("\""+saction+"\"");%>>
这样应该可以-------------------------------------
www.sooyle.com 中文搜索新秀 网络收藏夹
2、在Struts标签中,有部分标签可采用<% %>方式赋值,因为它直接保留原样输出给JSP服务器,再由JSP服务器进一步解析。
3、对于<html:form>,就不能用<% %>方式给action赋值,因为<html:form>在Struts解析时需要写上提取Bean名,这时由于还没到JSP服务器解析<% %>,所以用<% %>后<html:form>就取不到Bean名了,就会出错。同样,这里也不能用<html:write>来赋值。
4、如果改用<form>就可以用<% %>、<html:write>方式给action赋值了,因为这时Struts不用自己去找Bean名。
4、<html:form>解析方法如下(Struts源程序):
public int doStartTag() throws JspException { // Look up the form bean name, scope, and type if necessary
this.lookup(); // Create an appropriate "form" element based on our parameters
StringBuffer results = new StringBuffer();
results.append(this.renderFormStartElement()); results.append(this.renderToken()); ResponseUtils.write(pageContext, results.toString()); // Store this tag itself as a page attribute
pageContext.setAttribute(Constants.FORM_KEY, this, PageContext.REQUEST_SCOPE); this.initFormBean(); return (EVAL_BODY_INCLUDE); } /**
* Locate or create the bean associated with our form.
* @throws JspException
* @since Struts 1.1
*/
protected void initFormBean() throws JspException {
int scope = PageContext.SESSION_SCOPE;
if ("request".equalsIgnoreCase(beanScope)) {
scope = PageContext.REQUEST_SCOPE;
}
Object bean = pageContext.getAttribute(beanName, scope);
if (bean == null) {
if (type != null) {
// Backwards compatibility - use explicitly specified values
try {
bean = RequestUtils.applicationInstance(beanType);
if (bean != null) {
((ActionForm) bean).setServlet(servlet);
}
} catch (Exception e) {
throw new JspException(
messages.getMessage("formTag.create", type, e.toString()));
}
} else {
// New and improved - use the values from the action mapping
bean =
RequestUtils.createActionForm(
(HttpServletRequest) pageContext.getRequest(),
mapping,
moduleConfig,
servlet);
}
if (bean instanceof ActionForm) {
((ActionForm) bean).reset(mapping, (HttpServletRequest) pageContext.getRequest());
}
if (bean == null) {
throw new JspException(messages.getMessage("formTag.create", beanType));
}
pageContext.setAttribute(beanName, bean, scope);
}
pageContext.setAttribute(Constants.BEAN_KEY, bean, PageContext.REQUEST_SCOPE);
}