首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

在嵌入式jetty环境停运行struts2Annotation项目

2012-06-28 
在嵌入式jetty环境下运行struts2Annotation项目本人采用struts2的注解,配置好后可以在tomcat下运行,但是使

在嵌入式jetty环境下运行struts2Annotation项目

本人采用struts2的注解,配置好后可以在tomcat下运行,但是使用嵌入式jetty运行时,总是出现无法找到action的问题。

package com.action;import org.apache.struts2.convention.annotation.Action;import org.apache.struts2.convention.annotation.Namespace;import org.apache.struts2.convention.annotation.ParentPackage;import org.apache.struts2.convention.annotation.Result;import org.apache.struts2.convention.annotation.Results;import com.opensymphony.xwork2.ActionSupport;@Namespace(value="/tt")@ParentPackage(value="struts-default")@Results(   {   @Result(name="success",location="/hello.jsp"),   @Result(name="error",location="/hello.jsp")   })public class HelloAction extends ActionSupport{private String username;private String password;private String result;public String getResult() {return result;}public void setResult(String result) {this.result = result;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public String execute() throws Exception {result =this.getClass().getSimpleName();return SUCCESS;}/** * @return * @throws Exception */@Action(value="login",results={@Result(name="success",location="/hello.jsp"),@Result(name="error",location="/hello.jsp")})public String login()throws Exception{result =this.getClass().getSimpleName()+ username+":"+password;return SUCCESS;}}

?//========================================================================
//Copyright 2007 Mort Bay Consulting Pty. Ltd.
//------------------------------------
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//========================================================================

package jetty;

import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;

public class OneWebApp
{
??? public static void main(String[] args) throws Exception
??? {
??????? String jetty_home = "jetty";
??????? int port = 8020;

??????? Server server = new Server();
?????? ?
??????? Connector connector=new SelectChannelConnector();
??????? connector.setPort(port);
??????? server.addConnector(connector);
?????? ?
??????? WebAppContext webapp = new WebAppContext( "WebRoot", "/web");
?????? ?
??????? server.setHandler(webapp);
?????? ?
??????? server.start();
??? }
}

求指导。。。。。。。

1 楼 canuo 2012-05-06   遇到一样的问题,搞定了么?

热点排行