• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

struts超简单入门(二)

servlet/jsp 搞代码 7年前 (2018-06-18) 183次浏览 已收录 0个评论

【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" %>

http://www.gaodaima.com/40631.htmlstruts超简单入门(二)

<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"&gt;

<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>

欢迎大家阅读《struts超简单入门(二)》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:struts超简单入门(二)

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址