如果form 加上enctype="multipart/form-data" 后点提交没反应,就直接刷新了一下页面,ACTION对应的东西都没做,连表单验证都没做。 如果去掉 这段后都是可以的,我主要是想做文件上传,用的是MYFACES-EXTENSION ,
<t:inputFileUpload id="txtFile" value="#{productBean.myFile}" required="true" storage="file" </t:inputFileUpload>
用的是这个。
是不是过滤器有冲突?
org.ajax4jsf.Filter
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
org.apache.myfaces.component.html.util.ExtensionsFilter
我用到这么几个过滤器。
框架用到JSF,SPRING,HAIBERNATE
<t:inputFileUpload id="txtFile" value="#{productBean.myFile}" required="true" storage="file" </t:inputFileUpload>
用的是这个。
是不是过滤器有冲突?
org.ajax4jsf.Filter
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
org.apache.myfaces.component.html.util.ExtensionsFilter
我用到这么几个过滤器。
框架用到JSF,SPRING,HAIBERNATE
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="t"%>
<html>
<head>
<title>Main Page</title>
</head>
<body>
<f:view>
<h:form id="myForm" enctype="multipart/form-data">
<h:inputText id="txtMytext" value="#{productBean.imageResult}"
required="true"> </h:inputText>
<h:message for="txtMytext"></h:message>
<t:inputFileUpload id="txtFile" value="#{productBean.myFile}"
required="true"
storage="file" ></t:inputFileUpload>
<t:message for="txtFile"></t:message>
<h:commandButton id="cmd" action="#{productBean.saveProduct}" value="submit"></h:commandButton>
</h:form>
</f:view>
</body>
</html>
HTML 页面
原来是我的
<filter-mapping>
<filter-name>ExtensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
这段写错了, mapping 的NAME 少了个空格,没对应我的JSF servlet