埋め込みjetty環境でstruts 2 Annotationプロジェクトを実行する

3528 ワード

本人はstruts 2の注釈を採用し、構成後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();     } }
指導を求める......