欢迎光临
我们一直在努力

struts超简单入门(二)-JSP教程,Java技巧及代码

建站超值云服务器,限时71元/月

【hello.jsp】内容:

<%@ page contenttype="text/html;charset=utf-8" language="java" %>

<%@ taglib uri="/web-inf/struts-bean.tld" prefix="bean" %><%@ taglib uri="/web-inf/struts-html.tld" prefix="html" %><%@ taglib uri="/web-inf/struts-logic.tld" prefix="logic" %>

<html:html locale="true"><head>  <title><bean:message key="hello.jsp.title" /></title>  <html:base/></head>

<body>  <p><h2><bean:message key="hello.jsp.page.heading" /></h2></p>  <html:errors /><p>  <logic:present name="helloform" scope="request">    <h2>hello <bean:write name="helloform" property="person" />!</h2>  </logic:present>

  <html:form action="helloworld.do" focus="person">    <bean:message key="hello.jsp.prompt.person" />    <html:text property="person" size="20" maxlength="20" /><br> <html:submit property="submit" value="提交" /> <html:reset/>  </html:form><br>

  <html:img page="/struts-power.jpg" alt="powered by struts" /></body>

</html:html>

【struts-config.xml】内容:

<?xml version="1.0" encoding="utf-8"?><!doctype struts-config public "-//apache software foundation//dtd struts configuration 1.1//en"          "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>  <form-beans>    <form-bean name="helloform" type="com.javer.test.struts.hellofrom"/>  </form-beans>

  <action-mappings>    <action path="/helloworld" type="com.javer.test.struts.helloaction" name="helloform" scope="request" validate="true" input="/hello.jsp">   <forward name="sayhello" path="/hello.jsp" /> </action>  </action-mappings>

  <message-resources parameter="com.javer.test.struts.application" /></struts-config>

【web.xml】内容:

<?xml version="1.0" encoding="utf-8"?><!doctype web-app public "-//sun microsystems, inc.//dtd web application 2.3//en" "http://java.sun.com/dtd/web-app_2_3.dtd"><web-app>  <filter>    <filter-name>the webapp framework set character encoding</filter-name> <filter-class>com.javer.test.struts.encodingfilter</filter-class> <init-param>   <param-name>encoding</param-name>   <param-value>utf-8</param-value> </init-param>  </filter>  <filter-mapping>    <filter-name>the webapp framework set character encoding</filter-name>    <url-pattern>/*</url-pattern>  </filter-mapping>

  <servlet>    <servlet-name>action</servlet-name>    <servlet-class>org.apache.struts.action.actionservlet</servlet-class>    <init-param>      <param-name>config</param-name>      <param-value>/web-inf/struts-config.xml</param-value>    </init-param>    <load-on-startup>2</load-on-startup>  </servlet>

  <servlet-mapping>    <servlet-name>action</servlet-name>    <url-pattern>*.do</url-pattern>  </servlet-mapping>

  <taglib>    <taglib-uri>/web-inf/struts-bean.tld</taglib-uri>    <taglib-location>/web-inf/lib/struts-bean.tld</taglib-location>  </taglib>  <taglib>    <taglib-uri>/web-inf/struts-html.tld</taglib-uri>    <taglib-location>/web-inf/lib/struts-html.tld</taglib-location>  </taglib>  <taglib>    <taglib-uri>/web-inf/struts-logic.tld</taglib-uri>    <taglib-location>/web-inf/lib/struts-logic.tld</taglib-location>  </taglib></web-app>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » struts超简单入门(二)-JSP教程,Java技巧及代码
分享到: 更多 (0)

相关推荐

  • 暂无文章